Dynamic loading of c modules,question.
Andrew MacIntyre
andymac at bullseye.apana.org.au
Fri Sep 13 20:25:31 EDT 2002
[posted & mailed]
On Fri, 13 Sep 2002, hpyhpy wrote:
{...}
> /****************************/
> example.i
>
> /* File : example.i */
> %module example
>
> extern int gcd(int x, int y);
> extern double Foo;
> /****************************/
> And I do :
> #gcc -c example.c
> #swig -python example.i
> #gcc -c example_wrap.c -I/usr/local/include/python2.2/
> #gcc -G -Wl example.o example_wrap.o -o _examplecmodule.so
^
why the underscore here?
{...}
> So I wonder where is the "example.py"???
> So I can't "import example"
>
> Traceback (most recent call last):
> File "", line 1, in ?
> ImportError: No module named example
There would only be an example.py if you wrote it yourself. SWIG
generates the extension module, which you can directly use without a
wrapper in Python.
if you rename _examplemodule.so to examplemodule.so, it should work.
--
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370
andymac at pcug.org.au | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia
More information about the Python-list
mailing list