ubuntu cmake链接静态提升

时间:2018-03-29 19:50:59

标签: c++ boost cmake

我有一个c ++代码,它取决于boost jobb

我刚刚安装了这个

  

sudo apt-get install libboost-dev

和cmake我用过:

filesystem

我运行make和它的编译没有错误,但它编译为共享库 我只是搜索make it static所以我先做了我用

卸载libboost-dev
find_package( Boost  1.5.9 REQUIRED COMPONENTS filesystem system)  
MESSAGE("Boost information:") 
MESSAGE("  Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") 
MESSAGE("  Boost_LIBRARIES: ${Boost_LIBRARIES}") 
MESSAGE("  Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
target_link_libraries(project  ${Boost_LIBRARIES})

我从中下载了增强源 here

我下载了sudo apt-get purge --remove libboost-dev sudo apt-get purge --auto-remove libboost-dev

我在boost_1_66_0.tar.gz中解压缩并运行此命令:

home/build

以上所有操作都没有错误

但我无法将其链接到cmake以获得编译静态库我在cmake中尝试了这个:

./boostrap.sh
./b2 --target=static
 sudo ./b2 install

但似乎我没有链接,它显示了这个错误:

 set(Boost_INCLUDE_DIR home/build/boost)
 set(Boost_LIBRARY_DIR home/build/boost/stage/lib)
 find_package(Boost COMPONENTS system filesystem REQUIRED)
 include_directories(${Boost_INCLUDE_DIR})
 link_directories(${Boost_LIBRARY_DIR})

 add_executable(project main.cpp)
 target_link_libraries( main ${Boost_LIBRARIES} )

0 个答案:

没有答案