I have this C code:
... [SNIP] ...
for(Node = Plugin.Head; Node != NULL; Node = Node->Next) {//Create new python sub-interpreterNode->Interpreter = Py_NewInterpreter();if(Node->Interpreter == NULL) {Die("Py_NewInterpreter() failed");}//Create path to plugins main source filesnprintf(Filename, FILENAME_MAX, "%s/main.py", Node->File);//Convert filename to python stringPFilename = PyString_FromString(Filename);if(PFilename == NULL) {Die("PyString_FromString(%s) failed", Filename);}//Import plugin main source filePModule = PyImport_Import(PFilename);if(PModule == NULL) {Die("PyImport_Import(%s) failed", Filename);}//Deallocate filenamePy_DECREF(PFilename);//Get reference to onLoad function from modulePFunction = PyObject_GetAttrString(PModule, "onLoad");if(PFunction == NULL) {Die("PyObject_GetAttrString() failed");}
}
... [SNIP] ...
Which gives this error when compiled:
/tmp/ccXNmyPy.o: In function `LoadPlugins':
/home/alex/Code/Scribe/Scribe.c:693: undefined reference to `PyString_FromString'
collect2: error: ld returned 1 exit status
Python.h is included at the top of the source file.
I'm compiling with:
gcc -funwind-tables -rdynamic -I /usr/include/python2.7/ -g -o Scribe Scribe.c -lcurses `python-config --cflags` `python-config --ldflags` -Wall
I'm basing the code on the Python C-Api docs, from here:
http://docs.python.org/2/c-api/
Specifically:
http://docs.python.org/2/c-api/string.html?highlight=pystring_fromstring#PyString_FromString
I have no idea why this is happening, halp? =c