View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0013479 | CMake | CMake | public | 2012-08-17 05:23 | 2013-01-09 14:05 | ||||
Reporter | Markus Blatt | ||||||||
Assigned To | Brad King | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | x86_64 | OS | GNU/Linux | OS Version | Debian wheezy | ||||
Product Version | CMake 2.8.9 | ||||||||
Target Version | CMake 2.8.10 | Fixed in Version | CMake 2.8.10 | ||||||
Summary | 0013479: add_library documentation does not mention POSITION_INDEPENDENT_CODE property | ||||||||
Description | I need to used the object libraries for building libs out of serveral convenient libraries. When trying to build shared libraries by using set(BUILD_SHARED_LIBS ON) the compilation with gcc fails with "[100%] Building CXX object CMakeFiles/a.dir/dummy.cc.o [100%] Built target a Linking CXX shared library libb.so /usr/bin/ld: CMakeFiles/a.dir/dummy.cc.o: relocation R_X86_64_32 against `_ZSt4cout' can not be used when making a shared object; recompile with -fPIC CMakeFiles/a.dir/dummy.cc.o: could not read symbols: Bad value collect2: error: ld returned 1 exit status make[2]: *** [libb.so] Error 1 make[1]: *** [CMakeFiles/b.dir/all] Error 2 make: *** [all] Error 2 " | ||||||||
Steps To Reproduce | Setup the attached testcase and call cmake && make | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | ![]() | ||||||||
Relationships | |
Relationships |
Notes | |
(0030688) Brad King (manager) 2012-08-17 08:36 |
The BUILD_SHARED_LIBS option only affects whether add_library defaults to SHARED or STATIC. CMake has no idea what you're going to do with the object files in an OBJECT library. In CMake 2.8.9 you can set the POSITION_INDEPENDENT_CODE property: http://www.cmake.org/cmake/help/v2.8.9/cmake.html#prop_tgt:POSITION_INDEPENDENT_CODE [^] on the object library to get -fPIC. Add this line to your example: set_property(TARGET a PROPERTY POSITION_INDEPENDENT_CODE 1) |
(0030807) Markus Blatt (reporter) 2012-08-31 06:20 |
I did not know this property. Thanks a lot. Is it mentioned in the add_library documentation? Wouldn't it be more user-friendly to honor a supplied SHARED option? |
(0030809) Brad King (manager) 2012-08-31 07:40 |
Re 0013479:0030807: The property was just added in CMake 2.8.9. I've updated the documentation of add_library to mention it: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4eaea3c3 [^] |
(0032083) Robert Maynard (manager) 2013-01-09 14:05 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2012-08-17 05:23 | Markus Blatt | New Issue | |
2012-08-17 05:23 | Markus Blatt | File Added: testcase.tar.gz | |
2012-08-17 08:36 | Brad King | Note Added: 0030688 | |
2012-08-31 06:20 | Markus Blatt | Note Added: 0030807 | |
2012-08-31 07:40 | Brad King | Note Added: 0030809 | |
2012-08-31 07:40 | Brad King | Assigned To | => Brad King |
2012-08-31 07:40 | Brad King | Priority | high => normal |
2012-08-31 07:40 | Brad King | Severity | major => minor |
2012-08-31 07:40 | Brad King | Status | new => resolved |
2012-08-31 07:40 | Brad King | Resolution | open => fixed |
2012-08-31 07:40 | Brad King | Fixed in Version | => CMake 2.8.10 |
2012-08-31 07:40 | Brad King | Target Version | => CMake 2.8.10 |
2012-08-31 07:40 | Brad King | Summary | buildig shared libs from object libraries fails because of missing -fPIC opion => add_library documentation does not mention POSITION_INDEPENDENT_CODE property |
2013-01-09 14:05 | Robert Maynard | Note Added: 0032083 | |
2013-01-09 14:05 | Robert Maynard | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |