[C++-sig] Extending Python with not-basic-c++
seefeld at sympatico.ca
Sat Dec 2 16:06:23 CET 2006
David Sveningsson wrote:
> Stefan Seefeld skrev:
>>> As I said, it works but for each module I have to link against many of
>>> my c++ object files. So the same files is linked into many modules. What
>>> I mant to know if this is the way it has to be done or if there is a
>>> better way. Won't it be problematic if each module has it's own version
>>> of everything?
>> Don't you use shared libraries ? Sharing doesn't imply duplication.
> Yes, I compile the libraries like this (straight from the Makefile):
> And then linked like this:
> g++ CoreModule.o -g -lX11 -lGL -lGLU -shared -lboost_python -lpython2.4
> -shared -lboost_python -lpython2.4 -o ../../Game/Core.so
> But when I try to import the module into Python (import Core) i get the
> following error:
> Traceback (most recent call last):
> File "./foo.py", line 3, in ?
> import Core
> ImportError: /home/ext/workspace/06proj/Game/Core.so: undefined symbol:
> So I have to link with AutoreleasePool.o
No, you have to link with the (hopefully shared) library that contains AutoreleasePool.o.
That will only make your 'Core.so' python module aware of the library, so the dynamic
loader (presumably ld.so) can load it when you import the 'Core' module.
But this has nothing to do with boost.python, really.
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig