On 18.03.09 11:31:13, Eric Lemings wrote:
> 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?

You're doing something wrong, linking static libs into shared libs is not
supported on all platforms. You can make it work in on linux/x86-64 by
passing -fPIC when compiling the static lib (or was it the shared lib),
however this might not work on other platforms.

Andreas

-- 
You're being followed.  Cut out the hanky-panky for a few days.
_______________________________________________
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

Reply via email to