I must be doing something systematically wrong, because I have tried
this with various combinations of python and swig versions. Swigging std::vector eventually results in a compiler error involving SWIG_IndexError. Here is a simple example taken from the swig documentation (swig-1.3.27, but similar problems with swig-1.3.24; python-2.4.1): example.i: %module example %include "std_vector.i" namespace std { %template(vectori) vector<int>; %template(vectord) vector<double>; }; swig -c++ -python -I/opt/local/include/python2.4/ example.i g++ --shared -I/opt/local/include/python2.4/ -o _example example_wrap.cxx example_wrap.cxx: In function `PyObject* _wrap_vectori_pop(PyObject*, PyObject*)': example_wrap.cxx:3124: error: `SWIG_IndexError' undeclared (first use this function) example_wrap.cxx:3124: error: (Each undeclared identifier is reported only once foreach function it appears in.) example_wrap.cxx:3124: error: `SWIG_exception' undeclared (first use this function) example_wrap.cxx: In function `PyObject* _wrap_vectori___getslice__(PyObject*, PyObject*)': example_wrap.cxx:3161: error: `SWIG_exception' undeclared (first use this function) example_wrap.cxx: In function `PyObject* _wrap_vectori___setslice__(PyObject*, PyObject*)': <rest of the stream snipped> The SWIG_IndexError macro is defined in exception.i, but including doesn't change the results. %include "exception.i" doesn't change matters. However, if I copy the entire contents of exception.i into example.i, it works fine. What am I missing? I've googled for solutions to this problem without success. Thanks! -- Jeffery Collins ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Swig-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swig-user |
yes, it seems you have installed one version and compiling the examples
with another. Please check the Makefile and change something like SWIG = ...../swig to SWIG = ..../preinst-swig or just sync the swig version you have installed. Marcelo Jeffery D. Collins wrote: > I must be doing something systematically wrong, because I have tried > this with various combinations of python and swig versions. Swigging > std::vector eventually results in a compiler error involving > SWIG_IndexError. Here is a simple example taken from the swig > documentation (swig-1.3.27, but similar problems with swig-1.3.24; > python-2.4.1): > > example.i: > > %module example > %include "std_vector.i" > > namespace std { > %template(vectori) vector<int>; > %template(vectord) vector<double>; > }; > > > swig -c++ -python -I/opt/local/include/python2.4/ example.i > g++ --shared -I/opt/local/include/python2.4/ -o _example > example_wrap.cxx > > example_wrap.cxx: In function `PyObject* _wrap_vectori_pop(PyObject*, > PyObject*)': > example_wrap.cxx:3124: error: `SWIG_IndexError' undeclared (first use > this function) > example_wrap.cxx:3124: error: (Each undeclared identifier is reported > only once foreach function it appears in.) > example_wrap.cxx:3124: error: `SWIG_exception' undeclared (first use > this function) > example_wrap.cxx: In function `PyObject* > _wrap_vectori___getslice__(PyObject*, PyObject*)': > example_wrap.cxx:3161: error: `SWIG_exception' undeclared (first use > this function) > example_wrap.cxx: In function `PyObject* > _wrap_vectori___setslice__(PyObject*, PyObject*)': > > <rest of the stream snipped> > > The SWIG_IndexError macro is defined in exception.i, but including > doesn't change the results. %include "exception.i" doesn't change > matters. However, if I copy the entire contents of exception.i into > example.i, it works fine. > > What am I missing? I've googled for solutions to this problem without > success. > > Thanks! > > -- > Jeffery Collins > > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. > Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Swig-user mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/swig-user ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Swig-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swig-user |
In reply to this post by Jeffery D. Collins-2
Problem solved. I had a file named 'exception.i' in the current working
directory, which was being loaded instead of the system version. After renaming this file, the errors went away. -- Jeff Jeffery D. Collins wrote: > I must be doing something systematically wrong, because I have tried > this with various combinations of python and swig versions. Swigging > std::vector eventually results in a compiler error involving > SWIG_IndexError. Here is a simple example taken from the swig > documentation (swig-1.3.27, but similar problems with swig-1.3.24; > python-2.4.1): > > example.i: > > %module example > %include "std_vector.i" > > namespace std { > %template(vectori) vector<int>; > %template(vectord) vector<double>; > }; > > > swig -c++ -python -I/opt/local/include/python2.4/ example.i > g++ --shared -I/opt/local/include/python2.4/ -o _example > example_wrap.cxx > > example_wrap.cxx: In function `PyObject* _wrap_vectori_pop(PyObject*, > PyObject*)': > example_wrap.cxx:3124: error: `SWIG_IndexError' undeclared (first use > this function) > example_wrap.cxx:3124: error: (Each undeclared identifier is reported > only once foreach function it appears in.) > example_wrap.cxx:3124: error: `SWIG_exception' undeclared (first use > this function) > example_wrap.cxx: In function `PyObject* > _wrap_vectori___getslice__(PyObject*, PyObject*)': > example_wrap.cxx:3161: error: `SWIG_exception' undeclared (first use > this function) > example_wrap.cxx: In function `PyObject* > _wrap_vectori___setslice__(PyObject*, PyObject*)': > > <rest of the stream snipped> > > The SWIG_IndexError macro is defined in exception.i, but including > doesn't change the results. %include "exception.i" doesn't change > matters. However, if I copy the entire contents of exception.i into > example.i, it works fine. > > What am I missing? I've googled for solutions to this problem without > success. > > Thanks! > > -- > Jeffery Collins > > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. > Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Swig-user mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/swig-user ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Swig-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swig-user |
Aja, try then the safer
%include <exception.i> which, as you suspects, will include the one from the system library, not the pwd. Use that syntax for all the system files and you will have no more problems again, or at least one less. Marcelo Jeffery D. Collins wrote: > Problem solved. I had a file named 'exception.i' in the current > working directory, which was being loaded instead of the system > version. After renaming this file, the errors went away. > > -- > Jeff > > > Jeffery D. Collins wrote: > >> I must be doing something systematically wrong, because I have tried >> this with various combinations of python and swig versions. Swigging >> std::vector eventually results in a compiler error involving >> SWIG_IndexError. Here is a simple example taken from the swig >> documentation (swig-1.3.27, but similar problems with swig-1.3.24; >> python-2.4.1): >> >> example.i: >> >> %module example >> %include "std_vector.i" >> >> namespace std { >> %template(vectori) vector<int>; >> %template(vectord) vector<double>; >> }; >> >> >> swig -c++ -python -I/opt/local/include/python2.4/ example.i >> g++ --shared -I/opt/local/include/python2.4/ -o _example >> example_wrap.cxx >> >> example_wrap.cxx: In function `PyObject* _wrap_vectori_pop(PyObject*, >> PyObject*)': >> example_wrap.cxx:3124: error: `SWIG_IndexError' undeclared (first use >> this function) >> example_wrap.cxx:3124: error: (Each undeclared identifier is reported >> only once foreach function it appears in.) >> example_wrap.cxx:3124: error: `SWIG_exception' undeclared (first use >> this function) >> example_wrap.cxx: In function `PyObject* >> _wrap_vectori___getslice__(PyObject*, PyObject*)': >> example_wrap.cxx:3161: error: `SWIG_exception' undeclared (first use >> this function) >> example_wrap.cxx: In function `PyObject* >> _wrap_vectori___setslice__(PyObject*, PyObject*)': >> >> <rest of the stream snipped> >> >> The SWIG_IndexError macro is defined in exception.i, but including >> doesn't change the results. %include "exception.i" doesn't change >> matters. However, if I copy the entire contents of exception.i into >> example.i, it works fine. >> >> What am I missing? I've googled for solutions to this problem >> without success. >> >> Thanks! >> >> -- >> Jeffery Collins >> >> >> >> >> >> ------------------------------------------------------- >> SF.Net email is sponsored by: >> Tame your development challenges with Apache's Geronimo App Server. >> Download >> it for free - -and be entered to win a 42" plasma tv or your very own >> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php >> _______________________________________________ >> Swig-user mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/swig-user > > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. > Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Swig-user mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/swig-user ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Swig-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swig-user |
I hadn't actually included exception.i in my code. It took some hunting
around in the swig libraries to determine that one of *those* libraries were including it -- the std_*.i ones, I believe -- but found my local one instead. For example, find/grep exception.i in the swig library results in (among others): ./std/std_basic_string.i:1:%include <exception.i> ./std/std_container.i:2:%include <exception.i> ./std/std_except.i:17: %include "exception.i" Actually, there are quite a number of them that include "exception.i" rather than <exception.i>. In any case, Marcelo, thanks for pointing this out. Marcelo Matus wrote: > Aja, try then the safer > > %include <exception.i> > > which, as you suspects, will include the one from the system library, > not the pwd. > > Use that syntax for all the system files and you will have no more > problems again, > or at least one less. > > Marcelo > > > Jeffery D. Collins wrote: > >> Problem solved. I had a file named 'exception.i' in the current >> working directory, which was being loaded instead of the system >> version. After renaming this file, the errors went away. >> >> -- >> Jeff >> >> >> Jeffery D. Collins wrote: >> >>> I must be doing something systematically wrong, because I have tried >>> this with various combinations of python and swig versions. >>> Swigging std::vector eventually results in a compiler error >>> involving SWIG_IndexError. Here is a simple example taken from the >>> swig documentation (swig-1.3.27, but similar problems with >>> swig-1.3.24; python-2.4.1): >>> >>> example.i: >>> >>> %module example >>> %include "std_vector.i" >>> >>> namespace std { >>> %template(vectori) vector<int>; >>> %template(vectord) vector<double>; >>> }; >>> >>> >>> swig -c++ -python -I/opt/local/include/python2.4/ example.i >>> g++ --shared -I/opt/local/include/python2.4/ -o _example >>> example_wrap.cxx >>> >>> example_wrap.cxx: In function `PyObject* >>> _wrap_vectori_pop(PyObject*, PyObject*)': >>> example_wrap.cxx:3124: error: `SWIG_IndexError' undeclared (first >>> use this function) >>> example_wrap.cxx:3124: error: (Each undeclared identifier is >>> reported only once foreach function it appears in.) >>> example_wrap.cxx:3124: error: `SWIG_exception' undeclared (first use >>> this function) >>> example_wrap.cxx: In function `PyObject* >>> _wrap_vectori___getslice__(PyObject*, PyObject*)': >>> example_wrap.cxx:3161: error: `SWIG_exception' undeclared (first use >>> this function) >>> example_wrap.cxx: In function `PyObject* >>> _wrap_vectori___setslice__(PyObject*, PyObject*)': >>> >>> <rest of the stream snipped> >>> >>> The SWIG_IndexError macro is defined in exception.i, but including >>> doesn't change the results. %include "exception.i" doesn't change >>> matters. However, if I copy the entire contents of exception.i into >>> example.i, it works fine. >>> >>> What am I missing? I've googled for solutions to this problem >>> without success. >>> >>> Thanks! >>> >>> -- >>> Jeffery Collins >>> >>> >>> >>> >>> >>> ------------------------------------------------------- >>> SF.Net email is sponsored by: >>> Tame your development challenges with Apache's Geronimo App Server. >>> Download >>> it for free - -and be entered to win a 42" plasma tv or your very own >>> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php >>> _______________________________________________ >>> Swig-user mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/swig-user >> >> >> >> >> >> >> ------------------------------------------------------- >> SF.Net email is sponsored by: >> Tame your development challenges with Apache's Geronimo App Server. >> Download >> it for free - -and be entered to win a 42" plasma tv or your very own >> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php >> _______________________________________________ >> Swig-user mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/swig-user > > ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Swig-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swig-user |
Free forum by Nabble | Edit this page |