On Mon, Apr 29, 2013 at 12:27 PM, Andy Falanga (afalanga) <afalanga@xxxxxxxxxx> wrote: > Hello everyone, > > I have a library for both static compilation with C++ and a python module (exposed through boost python). The functionality is split so that everything C++ only is expected to be compiled into a set of static object files that are then wrapped into a single archive file. The python module must be compiled into a shared object file. Therefore, the build process builds a *.a for the static stuff and *.so for the python layer. > > I'm having issues with bringing the two together. Here is the compilation lines used for the various parts (excerpt from the makefiles): > > # the static archive library makefile is in a different directory from the shared > SOURCES = File1.cpp File2.cpp File3.cpp > outputdir/%.o: %.cpp > $(CPP) -I/path/for/includes -std=c++0x -c -o $@ $< > > outputdir/archive.a: > ar qc archive.a outputdir/*.o Not sure if this matters, but CPP is the C preprocessor. I would probably use something like: outputdir/%.o: %.cpp $(CXX) $(CXXFLAGS) -I/path/for/includes -std=c++0x -c -o $@ $< CXXFLAGS should probably include -fPIC and -shared. Otherwise, you can have problems in library constructors and destructors. Also, when linking an archive in the final executable, you will want to link with -Wl,--exclude-libs,ALL. Otherwise, you can get violations of the One Definition Rule (ODR) *if* two different libraries each include the archive. The symptom is often (from my experience) a glibc crash due to a double free triggered by the destructors during unload. Jeff