|
|
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):
GCC=g++
OPTIONS=-c -g -Wall -march=pentium-m -msse3 -pipe
FLAGS=-I../../Source/Include -DLINUX
CFLAGS=$(OPTIONS) $(FLAGS)
LDFLAGS=-g -lX11 -lGL -lGLU
OUTPUT=../../Game/Core.so
#Skipped the objects here...
PyModules: CFLAGS+=-I/usr/include/python2.4
PyModules: LDFLAGS+=-shared -lboost_python -lpython2.4
all: $(OBJS) PyModules
%.o : %.cpp Makefile
$(GCC) $(CFLAGS) $< -o
PyModules: $(PY_OBJS)
$(GCC) $(OBJS) $(LDFLAGS) -o $(OUTPUT)
So each source file is compiled like this:
g++ -c -g -Wall -march=pentium-m -msse3 -pipe -I../../Source/Include
-DLINUX -I/usr/include/python2.4
../../Source/Implementation/PythonModules/CoreModule.cpp -o CoreModule.o
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:
_ZN15AutoreleasePool9constructEv
So I have to link with AutoreleasePool.o
After I have linked with all objects that is required and creates
another module and imports it AFTER the core module I still get the same
error for the new module. The only way to get it working is to link with
those modules again but that creates to separate modules. For instance,
I have an event dispatcher in the core module. Another module I try to
create also needs the event dispatcher but since the is linked
separately into both modules they cannot communicate.
I don't want to have everything in a big module, I want to split things
up. I can live with a core module that have all code with circular
dependencies etc but I don't want everything in it.
Doesn't it compile the shared libraries as it should? Since they don't
seem to behave like one. I only have experience with creating shared
libraries in c/c++ for use with c/c++ but as I understood it was
basically the same?
--
//*David Sveningsson [eXt]*
Freelance coder | Game Development Student
http://sidvind.com
Thou shalt make thy program's purpose and structure clear to thy fellow
man by using the One True Brace Style, even if thou likest it not, for
thy creativity is better used in solving problems than in creating
beautiful new impediments to understanding.
_______________________________________________
C++-sig mailing list
C++-sig@xxxxxxxxxx
http://mail.python.org/mailman/listinfo/c++-sig
|
|