我需要Boost和一些组件库,包括program_options,但由于库版本命名,CMake的FIND_PACKAGE
命令在Debian上失败。如何强制它以最干净的方式找到program_options
库?
# CMakeLists.txt
SET( Boost_USE_STATIC_LIBS FALSE )
SET( Boost_USE_MULTITHREADED FALSE )
FIND_PACKAGE( Boost COMPONENTS program_options system thread REQUIRED)
这导致以下结果:
Unable to find the requested Boost libraries.
Boost version: 1.54.0
Boost include path: /usr/include
The following Boost libraries could not be found:
boost_program_options
检查我的提升库:
$ ls -F /usr/lib | grep boost
libboost_program_options.so.1.49.0
libboost_program_options.so.1.54.0
libboost_system.a
libboost_system.so@
libboost_system.so.1.54.0
libboost_thread.a
libboost_thread.so@
libboost_thread.so.1.49.0
libboost_thread.so.1.54.0
请注意,program_options
是唯一没有无版本名称的人(其他图书馆提供链接(由上面的@
表示),例如libboost_system.so -> libboost_system.so.1.54.0
)。据我所知,Debian 7.2没有提供创建这种链接的包,因此导致找不到program_options
。我能做什么不包括手动建立链接(我不能指望其他人使用我的包能够做到这一点)。
$ cmake -DBoost_DEBUG=ON
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:961 ] Searching for PROGRAM_OPTIONS_LIBRARY_RELEASE: boost_program_options-gcc47-1_54;boost_program_options-gcc47;boost_program_options-1_54;boost_program_options;boost_program_options
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:993 ] Searching for PROGRAM_OPTIONS_LIBRARY_DEBUG: boost_program_options-gcc47-d-1_54;boost_program_options-gcc47-d;boost_program_options-d-1_54;boost_program_options-d;boost_program_options;boost_program_options
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:961 ] Searching for SYSTEM_LIBRARY_RELEASE: boost_system-gcc47-1_54;boost_system-gcc47;boost_system-1_54;boost_system;boost_system
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:993 ] Searching for SYSTEM_LIBRARY_DEBUG: boost_system-gcc47-d-1_54;boost_system-gcc47-d;boost_system-d-1_54;boost_system-d;boost_system;boost_system
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:961 ] Searching for THREAD_LIBRARY_RELEASE: boost_thread-gcc47-1_54;boost_thread-gcc47;boost_thread-1_54;boost_thread;boost_thread
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:993 ] Searching for THREAD_LIBRARY_DEBUG: boost_thread-gcc47-d-1_54;boost_thread-gcc47-d;boost_thread-d-1_54;boost_thread-d;boost_thread;boost_thread
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1107 ] Boost_FOUND = FALSE
答案 0 :(得分:13)
没关系,结果安装libboost-program-options-dev
建立链接。
答案 1 :(得分:0)
boost
版(当前为1.72)或者,当需要的不是deb的较新版本(例如,当前的1.72
)时,则可以使用{{ 3}},其中包含解压缩后的boost-folder中的命令(例如program_options
):
.../boost_1_72_0/
可能的话,您可能会遵循$ sudo ./bootstrap.sh --with-libraries=program_options
$ sudo ./b2 install
的完整boost.org-website,并且先前已卸载deb(boost
)。