Correct Boost version found, linked against wrong one

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Correct Boost version found, linked against wrong one

Florian Lindner
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
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Correct Boost version found, linked against wrong one

Andreas Naumann
Hey Florian,


Am 12.03.19 um 13:53 schrieb Florian Lindner:

> 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

Can you run make with VERBOSE=1 and give as the output please?

To me it looks like, that cmake discards the library directory and links
with -lboost_filesystem instead of the fullpath. This happened in my
environment whenever the environment variable LIBRARY_DIR contains the
boost library directory.

Nevertheless, you should unset LIBRARY_DIR with cmake. Otherwise, the
compiler gcc will treat the folders in this variable as system folders.

>
> Thanks,
> Florian

Hth,
Andreas


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake