Sorry for posting it on the GNURadio group.But I did not find an answer on google.Can someone please help?
I am learning to use SWIG and while doing to first example in the manual something went wrong. Here is the example I am referring to: http://www.swig.org/Doc1.3/Introduction.html#n8 I am trying to build the python wrapper. I am running gentoo linux with SWIG 1.3.19 and python 2.2.2 I did these command and everything seemed to work: $ swig -python example.i $ gcc -c -fpic example.c example_wrap.c -I/usr/include/python2.2 #<--location of Python.h in gentoo $ gcc -shared example.o example_wrap.o -o _example.so I now have at this point all of these files in my home directory: example.i example.c example_wrap.c example.o example_wrap.o _example.so I then start python and try to import example: >>> import example Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: dynamic module does not define init function (initexample) >>> Now before anybody points me back to the manual, I realize that the manual addresses this: FROM THE MANUAL: ----------------------------------------------------------------------------------------------------------------- Another possible error is the following: >>> import example Traceback (most recent call last): File "", line 1, in ? ImportError: dynamic module does not define init function (init_example) >>> This error is almost always caused when a bad name is given to the shared object file. For example, if you created a file example.so instead of _example.so you would get this error. Alternatively, this error could arise if the name of the module is inconsistent with the module name supplied with the %module directive. Double-check the interface to make sure the module name and the shared object filename match. Another possible cause of this error is forgetting to link the SWIG-generated wrapper code with the rest of your application when creating the extension module. _________________________________________________________________________ From my above the description, you can see that none of the problems stated in the manual describe my problem. I have the correct name (_example.so). The name of the module directive is correct (I copied it from the manual, and double checked it, the line reads "%module example"). And the wrapper code should be properly linked because I copied the commands directly from the manual. Also, some other interesting things that I can do: 1. running $python -i example.py will import the module and allow me to do fact(4) 2. i cam inport _example to link to the object directly and I can do _example.fact(4). However, I want to be able to do things the way it is described in the manual. Another interesting thing is that my error in python says that the module does not define "initexample" and the manual describes the error as not defining "init_example". Note the lack of the underscore in the error I get. Could this be the problem? It is looking for initexample when it should be looking for init_example? __________________________________________________________ Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com _______________________________________________ Discuss-gnuradio mailing list [email protected] http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
