I'm starting the study of Python/C API and I make the first code to test some functions, I write this:
file: test.c
#include "Python.h"
int main() {
PyObject* none = Py_BuildValue("");
}
I compile with command:
gcc -I/usr/include/python2.7 test.c
I've the error undefined reference to `Py_BuildValue'
After I run:
gcc -I/usr/include/python2.7 --shared -fPIC hashmem.c
this compile without errors, but when I run the compiled file I've a
Segmentation fault (core dumped)
How do I set the gcc parameters?
I've ubuntu 12.04, python 2.7.3, gcc 4.6.3 and I installed python-dev.
Thanks.
main
, and you may want to build a shared object with e.g.gcc -Wall -fPIC -shared -I/usr/include/python2.7 test.c -o test.so
then do Python tricks todlopen
that./test.so
– Basile Starynkevitch Oct 18 '12 at 12:51gcc -I/usr/include/python2.7 test.c -lpython2.6
(or whatever version you're running). – Pablo Oct 18 '12 at 12:52