> cat CMakeLists.txt CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) PROJECT(cmakeshared) set (BUILD_SHARED_LIBS ON) SET (CMAKE_VERBOSE_MAKEFILE ON) add_library (mylib SHARED mysrc.cpp) > cat mysrc.cpp int myfunc(int c) { return c; } > mkdir build && cd build && cmake .. && make -- The C compiler identification is GNU 4.2.1 -- The CXX compiler identification is GNU 4.2.1 -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /home/cerutti/ctest/cmake-shared/build /usr/local/bin/cmake -H/home/cerutti/ctest/cmake-shared -B/home/cerutti/ctest/cmake-shared/build --check-build-system CMakeFiles/Makefile.cmake 0 /usr/local/bin/cmake -E cmake_progress_start /home/cerutti/ctest/cmake-shared/build/CMakeFiles /home/cerutti/ctest/cmake-shared/build/CMakeFiles/progress.marks make -f CMakeFiles/Makefile2 all make -f CMakeFiles/mylib.dir/build.make CMakeFiles/mylib.dir/depend cd /home/cerutti/ctest/cmake-shared/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/cerutti/ctest/cmake-shared /home/cerutti/ctest/cmake-shared /home/cerutti/ctest/cmake-shared/build /home/cerutti/ctest/cmake-shared/build /home/cerutti/ctest/cmake-shared/build/CMakeFiles/mylib.dir/DependInfo.cmake --color= Scanning dependencies of target mylib make -f CMakeFiles/mylib.dir/build.make CMakeFiles/mylib.dir/build /usr/local/bin/cmake -E cmake_progress_report /home/cerutti/ctest/cmake-shared/build/CMakeFiles 1 [100%] Building CXX object CMakeFiles/mylib.dir/mysrc.cpp.o /usr/bin/c++ -Dmylib_EXPORTS -o CMakeFiles/mylib.dir/mysrc.cpp.o -c /home/cerutti/ctest/cmake-shared/mysrc.cpp Linking CXX shared library libmylib.so /usr/local/bin/cmake -E cmake_link_script CMakeFiles/mylib.dir/link.txt --verbose=1 /usr/bin/c++ -fPIC -shared -Wl,-soname,libmylib.so -o libmylib.so CMakeFiles/mylib.dir/mysrc.cpp.o /usr/bin/ld: CMakeFiles/mylib.dir/mysrc.cpp.o: relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC CMakeFiles/mylib.dir/mysrc.cpp.o: could not read symbols: Bad value *** [libmylib.so] Error code 1 Stop in /usr/home/cerutti/ctest/cmake-shared/build. *** [CMakeFiles/mylib.dir/all] Error code 1 Stop in /usr/home/cerutti/ctest/cmake-shared/build. *** [all] Error code 1 Stop in /usr/home/cerutti/ctest/cmake-shared/build. >