[CMake] Correct Boost version found, linked against wrong one

Florian Lindner mailinglists at xgm.de
Tue Mar 12 08:53:26 EDT 2019


Hello,

I have a simple cmake file for a small project. That project uses boost and links again a shared lib that also uses boost:

find_library(precice precice PATHS $ENV{PRECICE_ROOT}/build $ENV{PRECICE_ROOT}/build/last)
find_package(Boost 1.60.0 REQUIRED COMPONENTS system program_options filesystem)

add_executable(preciceMap src/preciceMap.cpp src/common.cpp)
target_include_directories(preciceMap PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries(preciceMap ${Boost_LIBRARIES})
target_link_libraries(preciceMap ${precice})

output is:


:~/software/aste/build> cmake ..
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Cray Programming Environment 2.5.17 C
-- Check for working C compiler: /opt/cray/pe/craype/2.5.17/bin/cc
-- Check for working C compiler: /opt/cray/pe/craype/2.5.17/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Cray Programming Environment 2.5.17 CXX
-- Check for working CXX compiler: /opt/cray/pe/craype/2.5.17/bin/CC
-- Check for working CXX compiler: /opt/cray/pe/craype/2.5.17/bin/CC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build configuration: Debug
CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:725 (message):
  Imported targets not available for Boost version 106600
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1315 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:21 (find_package)


CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:725 (message):
  Imported targets not available for Boost version 106600
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1315 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:21 (find_package)


CMake Warning at /usr/share/cmake/Modules/FindBoost.cmake:725 (message):
  Imported targets not available for Boost version 106600
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake/Modules/FindBoost.cmake:1315 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:21 (find_package)


-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   system
--   program_options
--   filesystem
-- Found MPI_C: /opt/cray/pe/craype/2.5.17/bin/cc  
-- Found MPI_CXX: /opt/cray/pe/craype/2.5.17/bin/CC  
-- Configuring done
-- Generating done
-- Build files have been written to: /zhome/academic/HLRS/ipv/ipvflind/software/aste/build

:~/software/aste/build> make
Scanning dependencies of target preciceMap
[ 20%] Building CXX object CMakeFiles/preciceMap.dir/src/preciceMap.cpp.o
[ 40%] Building CXX object CMakeFiles/preciceMap.dir/src/common.cpp.o
[ 60%] Linking CXX executable preciceMap
/usr/bin/ld: warning: libboost_system.so.1.66.0, needed by /zhome/academic/HLRS/ipv/ipvflind/software/precice/build/last/libprecice.so, may conflict with libboost_system.so.1.54.0
/usr/bin/ld: warning: libboost_filesystem.so.1.66.0, needed by /zhome/academic/HLRS/ipv/ipvflind/software/precice/build/last/libprecice.so, may conflict with libboost_filesystem.so.1.54.0
/usr/bin/ld: warning: libboost_program_options.so.1.66.0, needed by /zhome/academic/HLRS/ipv/ipvflind/software/precice/build/last/libprecice.so, may conflict with libboost_program_options.so.1.54.0
/usr/bin/ld: CMakeFiles/preciceMap.dir/src/common.cpp.o: undefined reference to symbol '_ZN5boost15program_options3argB5cxx11E'
/opt/hlrs/tools/boost/1.66.0/lib/libboost_program_options.so.1.66.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/preciceMap.dir/build.make:124: recipe for target 'preciceMap' failed
make[2]: *** [preciceMap] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/preciceMap.dir/all' failed
make[1]: *** [CMakeFiles/preciceMap.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2



CMake finds boost 1.66 but why does it try to link against 1.54.0? $BOOST_ROOT is set and $LIBRARY_PATH, $LD_LIBRARY_PATH and $CPLUS_INCLUDE_PATH are also set appropriately.

:~/software/aste/build> ls $BOOST_ROOT/lib/*filesystem*
/opt/hlrs/tools/boost/1.66.0/lib/libboost_filesystem.a  /opt/hlrs/tools/boost/1.66.0/lib/libboost_filesystem.so  /opt/hlrs/tools/boost/1.66.0/lib/libboost_filesystem.so.1.66.0

:~/software/aste/build> ls /usr/lib64/*filesystem*
/usr/lib64/libboost_filesystem-mt.so  /usr/lib64/libboost_filesystem.so  /usr/lib64/libboost_filesystem.so.1.54.0

Maybe it prefers the -mt variants? But how can I get it to link against the correct files, i.e., 1.66?

Or is the "DSO missing from command line" another problem? All I found about that is that boost_system should be added, but that's already the case.

cmake version is 3.5.2

Thanks,
Florian


More information about the CMake mailing list