[CMake] Problem linking static lib into shared lib on Linux

Eric Lemings eric at rebit.com
Wed Mar 18 13:31:13 EDT 2009


When I try to link a static library into a shared library on SUSE Linux
11, I get the following link error:

/usr/bin/c++  -fPIC   -shared -Wl,-soname,libbar.so -o libbar.so
CMakeFiles/shared_bar_lib.dir/Bar.cpp.o
CMakeFiles/shared_bar_lib.dir/__/__/include/moc_Bar.cxx.o
-L/my/build/path/archive -L/my/build/path/runtime -lfoo -lQtGui -lpng
-lSM -lICE -lXi -lXrender -lXrandr -lXcursor -lXinerama -lXfixes
-lfreetype -lfontconfig -lXext -lX11 -lm -lQtCore -lz -lrt -lpthread
-ldl -Wl,-rpath,/my/build/path/archive:/my/build/path/runtime
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld:
/my/build/path/archive/libfoo.a(modules.cpp.o): relocation
R_X86_64_32 against `a local symbol' can not be used when making a
shared object; recompile with -fPIC
/my/build/path/archive/libfoo.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [library/Bar/libbar.so] Error 1

Is this a problem with CMake or am I doing something wrong?

Thanks,
Eric.



More information about the CMake mailing list