On 30. Sep, 2010, at 13:30 , David Aldrich wrote: > Hi Michael > >> So, the options are: >> >> - use -whole-archive as you do now >> - make the Kernel library shared >> - link the dlopen'ed libraries against Kernel > > Thanks very much - I understand. I think I will keep the -whole-archive > method. > > However, now I'm worried about how I link in the Python library: > > /usr/bin/c++ -O3 -DNDEBUG -Wall -m64 -o myProj -rdynamic -Wl,-whole-archive > Kernel/libKernel.a -Wl,-no-whole-archive -ldl -lpython2.4 > > The dlopen'ed libraries may use the Python library. I guess I could include > it in the -whole-archive part, but perhaps it would be better to link each > shared library against Python. Would you agree? >
Unless the python library is static (which it AFAIK almost never is) you should be safe. > Sorry that I am now off topic w.r.t cmake. > > By the way, I think I am pretty much there with changing our build system > from manually coded makefiles to cmake. I like cmake! Thanks for all your > help in getting there. The support on this list is excellent. ;-) well, CMake does have its quirks and dark corners, but in general I find it to be much preferable over anything else I've ever seen so far... Michael > > Best regards > > David > >> -----Original Message----- >> From: Michael Wild [mailto:them...@gmail.com] >> Sent: 30 September 2010 12:20 >> To: David Aldrich >> Cc: cmake@cmake.org >> Subject: Re: [CMake] How to specify -fpic ? >> >> >> On 30. Sep, 2010, at 13:05 , David Aldrich wrote: >> >>> Hi >>> >>> Ok, by following the link to the wiki suggested by Michael Loose, I used: >>> >>> target_link_libraries( myProj -Wl,-whole-archive Kernel >>> -Wl,-no-whole-archive) >>> >>> This has fixed my problem. The executable links and runs correctly. >>> >>> My link command is now: >>> >>> /usr/bin/c++ -O3 -DNDEBUG -Wall -m64 -Wl,--export-dynamic -o myProj - >> Wl,-whole-archive Kernel/libKernel.a -Wl,-no-whole-archive -ldl -lpython2.4 >>> >>> I don't need portability so I think this is ok. >>> >>> Michael Wild wrote: >>> >>>> The -whole-archive flag is pretty useless with executables (unless, >>>> you plan to use it as a library too, but that is outlandish). >>>> --export-dynamic may be also necessary, if your dlopen'ed libraries >>>> use symbols in your executable. >>> >>> So my concern is now: am I being 'outlandish' ? The dlopen'ed libraries do >> use functions in libKernel.a that is linked to the executable. Is this >> outlandish? Is there a better way? >> >> The "outlandish" referred to using an executable also as a library, so you're >> fine :-) But I think I found the reason for why you need this -whole-archive >> flag: Since your executable doesn't use all of the functions in the Kernel >> library, the linker throws them away. This results in your dlopen'ed >> functions to fail. >> >> So, the options are: >> >> - use -whole-archive as you do now >> - make the Kernel library shared >> - link the dlopen'ed libraries against Kernel >> >> Michael >> > -- There is always a well-known solution to every human problem -- neat, plausible, and wrong. H. L. Mencken
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake