CMake linking Boost: cannot find -lboost_program_options
CMake linking Boost: cannot find -lboost_program_options
我想在Linux上使用C 中的命令行标志来使用Boosts支持。我使用cmake来构建应用程序,但是我遇到了一个错误"找不到-lboost_program_options"。库BOOST_PROGRAGIN_OPTIONS是使用BJAM独立构建的,库位于Boost目录的舞台/LIB子目录中。
有什么作用:一种解决方案是使用link_directories添加阶段/lib库,但是cmake手册状态:
请注意,此命令很少需要。find_package()返回的库位置和find_library()是绝对路径。
,这不应该是内在的。
我想工作的东西:
使用find_package应该足够了,但这是不起作用的,这是cmakelists:
cmake_minimum_required(VERSION 3.6)
project(inp_manipulation)
set(CMAKE_CXX_STANDARD 11)
include_directories(includes lib/boost_1_62_0 lib/)
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "lib/boost_1_62_0")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "lib/boost_1_62_0/stage/lib")
find_package(Boost 1.62.0)
include_directories(${Boost_INCLUDE_DIR})
file(GLOB SOURCES *.cpp)
set(MAIN_FILE main.cpp)
set(SOURCE_FILES ${SOURCES})
add_executable(inp_manipulation ${MAIN_FILE} ${SOURCE_FILES} )
target_link_libraries(inp_manipulation -static-libgcc -static-libstdc++ boost_program_options)
问题
cmakelists中的错误在哪里?
预先感谢!
首先,您必须告诉cmake您需要boost的特定组件库:
find_package(Boost 1.62.0 COMPONENTS program_options)
第二,始终使用boostfind.cmake
的输出变量target_link_libraries(inp_manipulation -static-libgcc -static-libstdc++ ${Boost_LIBRARIES})
文档在这里:https://cmake.org/cmake/help/v3.0/module/findboost.html
输出变量为:
boost_found-如果找到标题和请求的库
boost_include_dirs - boost Include Directories
BOOST_LIBRARY_DIRS - boost库的链接目录
boost_libraries - 要链接的boost组件库
etc
相关文章:
- Monty Hall program c++
- "Program ended with exit code: 0"出现在我的输出的开头?
- LCM program in C++
- 为什么 C++ 编译器在"c:program filesgnu emacsinclude"中查找包含文件?
- 在 EAX 模式下加密数据时"program has stopped working"
- 为什么删除执行组件指针会导致"Program.exe has triggered a breakpoint"
- for(;;) vs do..while() for main program loop
- C++ "Program has stopped working" - ROT-107(凯撒密码)
- OS X Eclipse C++ "Program File Does Not Exist"
- 在 Eclipse.It 中运行C++代码时出错,'Your program cannot output..'
- 如何设置Visual Studio来调试DLL ("Unable to start program error")
- 标准Windows 7用户如何能够删除C:Program Files下的文件
- xlC 警告,"The NOSTRICT option has the potential to alter the semantics of a program"
- 树莓派"error: stray 255 in program"
- 错误"<url> is not recognized as an internal or external command, operable program or batch file.
- 错误 PRJ0002:错误结果 -1073741515 从"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.
- 很多杂散错误 - "error: stray ‘210’ in program in C++"
- free.c 抛出异常并带有"this program has stopped working"
- Ubuntu SDL program
- C++排序程序中"Stray 1 in program"错误