[CMake] How to specify -fpic ?

Michael Wild themiwi at gmail.com
Thu Sep 30 02:38:56 EDT 2010


On 29. Sep, 2010, at 18:25 , David Aldrich wrote:

> Hi
> 
> My C++ code consists of an executable and several shared libraries.
> 
> With my CMake build files, I find that the executable fails to load the shared libraries ( the dlopen() call results in error 'undefined symbol...' ).
> 
> The software works fine under our production build system that uses manually coded makefiles.
> 
> I notice that the production system linker command invokes -fpic, while CMake uses -fPIC. I am wondering if that is the reason.
> 
> I set the compile flags with:
> 
> set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -Wall -m64" )
> 
> How can I replace -fPIC with -fpic in CMake please?
> 
> Best regards
> David


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). So I really doubt this is the problem. Are you using -fvisibility=hidden somewhere?

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/84707016/attachment.pgp>


More information about the CMake mailing list