MantisBT - CMake
View Issue Details
0013663CMake(No Category)public2012-11-08 11:372014-06-02 08:37
sebp 
Brad King 
normalmajorhave not tried
closedfixed 
LinuxFedora17
CMake 2.8.9 
CMake 3.0CMake 3.0 
0013663: FindBoost documentation example should clarify it only finds static libraries
FindBoost does not find any libraries. The actual library is e.g. located at /usr/lib64/libboost_program_options-mt.so on Fedora 17 which is not recognized by CMake.
Create a project which needs to link to boost library. Running cmake . -DBoost_DEBUG=TRUE -DBOOST_LIBRARYDIR=/usr/lib64 results in

-- [ /usr/share/cmake/Modules/FindBoost.cmake:566 ] _boost_TEST_VERSIONS = 1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42
-- [ /usr/share/cmake/Modules/FindBoost.cmake:568 ] Boost_USE_MULTITHREADED = ON
-- [ /usr/share/cmake/Modules/FindBoost.cmake:570 ] Boost_USE_STATIC_LIBS = ON
-- [ /usr/share/cmake/Modules/FindBoost.cmake:572 ] Boost_USE_STATIC_RUNTIME = OFF
-- [ /usr/share/cmake/Modules/FindBoost.cmake:574 ] Boost_ADDITIONAL_VERSIONS =
-- [ /usr/share/cmake/Modules/FindBoost.cmake:576 ] Boost_NO_SYSTEM_PATHS =
-- [ /usr/share/cmake/Modules/FindBoost.cmake:644 ] Declared as CMake or Environmental Variables:
-- [ /usr/share/cmake/Modules/FindBoost.cmake:646 ] BOOST_ROOT =
-- [ /usr/share/cmake/Modules/FindBoost.cmake:648 ] BOOST_INCLUDEDIR =
-- [ /usr/share/cmake/Modules/FindBoost.cmake:650 ] BOOST_LIBRARYDIR = /usr/lib64
-- [ /usr/share/cmake/Modules/FindBoost.cmake:652 ] _boost_TEST_VERSIONS = 1.56.0;1.56;1.55.0;1.55;1.54.0;1.54;1.53.0;1.53;1.52.0;1.52;1.51.0;1.51;1.50.0;1.50;1.49.0;1.49;1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42
-- [ /usr/share/cmake/Modules/FindBoost.cmake:734 ] location of version.hpp: /usr/include/boost/version.hpp
-- [ /usr/share/cmake/Modules/FindBoost.cmake:753 ] version.hpp reveals boost 1.48.0
-- [ /usr/share/cmake/Modules/FindBoost.cmake:785 ] guessed _boost_COMPILER = -gcc47
-- [ /usr/share/cmake/Modules/FindBoost.cmake:795 ] _boost_MULTITHREADED = -mt
-- [ /usr/share/cmake/Modules/FindBoost.cmake:838 ] _boost_RELEASE_ABI_TAG = -
-- [ /usr/share/cmake/Modules/FindBoost.cmake:840 ] _boost_DEBUG_ABI_TAG = -d
-- [ /usr/share/cmake/Modules/FindBoost.cmake:883 ] _boost_LIBRARY_SEARCH_DIRS = /usr/lib64;/usr/include/lib;/usr/include/../lib;/usr/include/stage/lib;C:/boost/lib;C:/boost;/boost/boost_1_48_0/lib;/boost/boost_1_48/lib;/boost/lib;/boost;/sw/local/lib
-- [ /usr/share/cmake/Modules/FindBoost.cmake:961 ] Searching for PROGRAM_OPTIONS_LIBRARY_RELEASE: boost_program_options-gcc47-mt-1_48;boost_program_options-gcc47-mt;boost_program_options-mt-1_48;boost_program_options-mt;boost_program_options
-- [ /usr/share/cmake/Modules/FindBoost.cmake:993 ] Searching for PROGRAM_OPTIONS_LIBRARY_DEBUG: boost_program_options-gcc47-mt-d-1_48;boost_program_options-gcc47-mt-d;boost_program_options-mt-d-1_48;boost_program_options-mt-d;boost_program_options-mt;boost_program_options
-- [ /usr/share/cmake/Modules/FindBoost.cmake:1107 ] Boost_FOUND = FALSE
CMake Error at /usr/share/cmake/Modules/FindBoost.cmake:1191 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.48.0

  Boost include path: /usr/include

  The following Boost libraries could not be found:

          boost_program_options

  No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.
Call Stack (most recent call first):
  CMakeLists.txt:9 (find_package)


-- Configuring incomplete, errors occurred!
No tags attached.
related to 0014235closed Brad King FindBoost should clarify when "static" libraries are not found 
zip boost-example.zip (952) 2012-11-08 11:37
https://public.kitware.com/Bug/file/4558/boost-example.zip
Issue History
2012-11-08 11:37sebpNew Issue
2012-11-08 11:37sebpFile Added: boost-example.zip
2012-11-08 13:20Brad KingNote Added: 0031497
2012-11-08 13:25Brad KingNote Added: 0031498
2012-11-08 14:02sebpNote Added: 0031499
2012-11-08 14:09Brad KingNote Added: 0031500
2012-11-08 14:12sebpNote Added: 0031501
2012-11-08 14:18Brad KingNote Added: 0031502
2012-11-08 14:18Brad KingStatusnew => resolved
2012-11-08 14:18Brad KingResolutionopen => no change required
2012-11-08 14:28sebpNote Added: 0031503
2012-11-08 14:28sebpStatusresolved => feedback
2012-11-08 14:28sebpResolutionno change required => reopened
2012-11-08 14:33Brad KingNote Added: 0031504
2013-11-01 11:42Brad KingNote Added: 0034308
2013-11-01 11:42Brad KingAssigned To => Brad King
2013-11-01 11:42Brad KingStatusfeedback => resolved
2013-11-01 11:42Brad KingResolutionreopened => fixed
2013-11-01 11:42Brad KingFixed in Version => CMake 3.0
2013-11-01 11:42Brad KingTarget Version => CMake 3.0
2013-11-01 11:42Brad KingSummaryFindBoost.cmake does not find => FindBoost documentation example should clarify it only finds static libraries
2013-11-01 11:42Brad KingRelationship addedrelated to 0014235
2013-11-01 11:44Brad KingNote Added: 0034309
2014-06-02 08:37Robert MaynardNote Added: 0035977
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0031497)
Brad King   
2012-11-08 13:20   
Does this still happen with CMake 2.8.10.1?
(0031498)
Brad King   
2012-11-08 13:25   
Also please try a recent nightly version:

 http://www.cmake.org/files/dev/?C=M;O=D [^]

Since 2.8.10 there has been a major cleanup of FindBoost:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=634c8bf4 [^]
(0031499)
sebp   
2012-11-08 14:02   
I just tried with nightly version cmake-2.8.10.20121107-g58dd7, the problem still persists.
(0031500)
Brad King   
2012-11-08 14:09   
Your example does

 set(Boost_USE_STATIC_LIBS ON)

but you say "The actual library is e.g. located at /usr/lib64/libboost_program_options-mt.so" which is a shared library.
(0031501)
sebp   
2012-11-08 14:12   
You are right, but you should update the description of FindBoost then where I got this from:

# Example to find Boost headers and some libraries:
# set(Boost_USE_STATIC_LIBS ON)
# set(Boost_USE_MULTITHREADED ON)
# set(Boost_USE_STATIC_RUNTIME OFF)
# find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...)
# if(Boost_FOUND)
# include_directories(${Boost_INCLUDE_DIRS})
# add_executable(foo foo.cc)
# target_link_libraries(foo ${Boost_LIBRARIES})
# endif()
(0031502)
Brad King   
2012-11-08 14:18   
It's an example, not "this will do exactly what you want in all situations".
The example is a jumping off point to see how it works. Read the docs for each option to see what it does and how to tune it to your situation.

Note the docs have been completely rewritten since 2.8.10:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/FindBoost.cmake;hb=c31e119d [^]

though the same example still appears.
(0031503)
sebp   
2012-11-08 14:28   
Well, the example uses "system", which according to http://www.boost.org/doc/libs/1_52_0/more/getting_started/unix-variants.html#header-only-libraries [^] has to be built. A short note about that the value of Boost_USE_STATIC_LIBS depends on how Boost was built, would be very helpful.
(0031504)
Brad King   
2012-11-08 14:33   
The new documentation already says:

# Boost libraries come in many variants encoded in their file name. Users or
# projects may tell this module which variant to find by setting variables:
...
# Boost_USE_STATIC_LIBS - Set to ON to force the use of the static
# libraries. Default is OFF.
(0034308)
Brad King   
2013-11-01 11:42   
Re 0013663:0031501: I've updated the FindBoost documentation example to mention that it is for finding static libraries:

 FindBoost: Clarify example static libs option
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f53878b0 [^]
(0034309)
Brad King   
2013-11-01 11:44   
As discussed in 0014235 CMake 2.8.12 now mentions in the failure message that it was looking for static libraries in this case.
(0035977)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.