[C++-sig] Python ImportError : undefined symbol
Jonathan Brandmeyer
jbrandmeyer at earthlink.net
Thu Feb 3 22:07:16 CET 2005
On Thu, 2005-02-03 at 21:36 +0100, neuroo at kouette.com wrote:
> Hi
> I got a problem with boost 1.32 & gcc 3.3.4 on a debian while trying to build a dynamic library.
> I am building the library with a Makefile like this one (but with more sources):
>
> LINKING=-L/usr/local/lib -lpython2.2 -lboost_python -DBOOST_PYTHON_STATIC_MODULE
> /usr/local/lib/libboost_python-gcc.a
> USR_PATH=-I/usr/local/include/boost-1_32 -I/usr/include/python2.2
>
> sample.o: sample.cpp
> g++ -c -Wall -O3 -fPIC sample.cpp $(USR_PATH)
>
> sample.so: sample.o
> g++ -shared -fPIC sample.o -o sample.so $(LINKING)
>
> The compiler does his work & when i try to import sample.so on python (2.3) i have an:
> ImportError: ./PL.so: undefined symbol: _ZN15LagrangianParamC1ER5ModelSs
> For more informations, if it's not a false compilation way, LagrangianParam::Model is a private
> pointer to a class (Model) defined in an other source...
This problem isn't Boost.Python specific. Your plugin is not linked to
the library that includes the definition of that missing symbol. Add
-lmy_library_containing_the_missing_symbol to your linker flags. (Note
also that c++filt decodes that undefined symbol to a different function
than what you indicated.)
To catch these errors at link time rather than runtime, add -lpython2.2
-Wl,-no-undefined (and possibly -Wl,--warn-once) to your linker options.
HTH,
-Jonathan
More information about the Cplusplus-sig
mailing list