[C++-sig] A few questions about embedding python

Colin Goudie colin.goudie at gmail.com
Wed Mar 16 07:01:52 CET 2005


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



More information about the Cplusplus-sig mailing list