A few questions about embedding python
I'm using boost 1.32.0 with python 2.4 When I compile I get the python libraries created at boost\bin\boost\libs\python\build\ with the static library at boost\bin\boost\libs\python\build\libboost_python.lib\vc-7_1\debug\threading-multi\libboost_python-vc71-mt-gd-1_32.lib and the dynamic at boost\bin\boost\libs\python\build\boost_python.dll\vc-7_1\debug\threading-multi\boost_python-vc71-mt-gd-1_32.lib When I'm linking my program if I link against the static (Because I thought you had to do that for embedding) I get lots of unresolved external symbols that seem to come from boosts python library. If I link instead to the lib that belongs to the dll, and place the dll in with my exe it runs fine. ?? Do I need static linking on windows for embedding? The other question is with regards to exposing c++ classes to a python script loaded from a file. I have something like this in my c++ code BOOST_PYTHON_MODULE(truckstate) { class_<TruckState>("TruckState") .def("goLoading", &TruckState::goLoading) .def("gowaiting", &TruckState::goWaiting); } In my python script when I try to import truckstate I get an exception thrown saying it can't find the module truckstate Most of the examples I've seen importing c++ classes are when they are extending python not embedding. Do I need to use Python C/API to import my truckstate module or something?? Thanks
Hi,
?? Do I need static linking on windows for embedding?
It seems that you answered your own question, as it runs fine with the DLL, embedding is OK with dynamic linking. If you absolutely need static linking with BPL, perhaps you could send a sample of those linking errors you mentionned.
Most of the examples I've seen importing c++ classes are when they are extending python not embedding. Do I need to use Python C/API to import my truckstate module or something??
You effectively have to "declare" your module by calling : PyImport_AppendInittab("truckstate", inittruckstate); before the Py_Initialize() call, and I think that should do the trick ! HTH, Nicolas.
participants (2)
-
Colin Goudie -
Nicolas Lelong