[CMake] How to specify -fpic ?

Michael Wild themiwi at gmail.com
Thu Sep 30 05:25:20 EDT 2010


On 30. Sep, 2010, at 11:15 , David Aldrich wrote:

> Hi Michael
> 
> Thanks for your reply.
> 
>> The only difference between -fpic and -fPIC is that the latter has no limit
>> on the size of the global offsets table and this is only relevant for the
>> m68k, PowerPC and SPARC architectures (according to the GCC manual page). 
> 
> Yes, we aren't using those architectures.
> 
>> Are you using -fvisibility=hidden somewhere?
> 
> No.
> 
>> Is this option the only difference of the link commands?
> 
> Actually, the shared library linker commands are similar but the executable linker commands are quite different.
> 
> CMake:
> 
> /usr/bin/c++ -O3 -DNDEBUG -Wall -m64 -o myProj -rdynamic Kernel/libKernel.a -lpython2.4
> 
> Manual make:
> 
> g++ -o myProj -ldl -Wl,-whole-archive,-export-dynamic ../Kernel/libKernel.a  -lboost_python-mt -lpython2.4 -Wl,--no-whole-archive
> 
> I will have to analyse these flags. Any thoughts on the use of -whole-archive/--no-whole-archive here please?
> 
> BR
> 
> David

For one, you are missing -ldl. Add ${CMAKE_DL_LIBS} to your target_link_libraries call. 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.

Michael

--
There is always a well-known solution to every human problem -- neat, plausible, and wrong.
H. L. Mencken

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100930/5bd5720f/attachment.pgp>


More information about the CMake mailing list