[CMake] relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC

Bill Hoffman bill.hoffman at kitware.com
Thu May 31 09:37:57 EDT 2007


Mathieu Malaterre wrote:
> Hello,
>
>  I have the following two targets:
>
> ADD_LIBRARY(foo STATIC ${foo_C_SRCS}) # C files
> ADD_LIBRARY(bla SHARED ${bla_CPP_SRCS}) # CXX files
> TARGET_LINK_LIBRARIES(bla foo)
>
>  When compiled with cmake on a 64bits machine I am getting:
>
> ...
> relocation R_X86_64_32 can not be used when making a shared object;
> recompile with -fPIC
> ...
>
>  Is this ok on most system, or there something against static lib
> used in a shared lib ?
As a general rule it is not "portable" to link a static library into a 
shared one.
However, on most linux systems this is allowed.   64 bit systems
do not allow this.   If you add -fPIC to your
CFLAGS for the static library it should work, at least with gcc.  

-Bill



More information about the CMake mailing list