I am trying to use .c program in python script with SWIG. To start with, I installed SWIG and trying simple example from tutorial swig webpage.
I am using Raspberry Pi with Raspbian GNU/Linux 9.4 (stretch)
This is what I do:
1. swig -python example.i
- great, this created two new files: 'example.py' and 'example_wrap.c'
2. gcc -fpic -I/usr/include/python2.7 -c example_wrap.c
- this creates 'example_wrap.o' file
3. compile example.c in Geany; this gives 'example.o' file
4. gcc -shared example.o example_wrap.o -o example.so
- now a new file 'example.so' is created.
Time to try it:
python
I am using Python 2.7.13 here
>>>import example
And this gives traceback:
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initexample)
How to sort this problem out?