File structure:
Foo/
list.so
main.cpp
list.cpp
boost_wrapper.cpp
main.cpp code:
#include <Python.h>
#include "list.cpp"
int main(int argc, char *argv[]){
PyObject *pimport;
pimport=PyString_FromString("list");
Py_SetProgramName(argv[0]);
Py_Initialize();
PyImport_Import(pimport);
/*PyRun_SimpleString("l=list.LinkedList()");
PyRun_SimpleString("l.insert(\"N\", 9)");
PyRun_SimpleString("l.display()");*/
Py_Finalize();
}
ERROR:
ImportError: No module named list
However if I run python from bash, I'm able to successfully import the module and use all functions defined. I've also tried to import using just PyRun_SimpleString with no avail.
I suspect the current working directory is invisible to the Python Interpreter called by Py_Initialize().