linux下編譯Boost庫
阿新 • • 發佈:2018-05-25
eas module cmak lease 加載 IT AI c-c++ python re
下載源碼
boost_1_66_0.tar.gz
生成編譯工具
# tar axf boost_1_66_0.tar.gz
# cd boost_1_66_0
# yum install gcc gcc-c++ python-devel cmake -y
# ./bootstrap.sh
編譯64位boost庫
# ./b2 install --with-system --with-thread --with-date_time --with-regex --with-serialization --with-python link=shared runtime-link=shared threading=multi debug
設置boost動態庫加載路徑
# tee /etc/ld.so.conf.d/boost-x86_64.conf << EOF
/usr/local/lib
EOF
# ldconfig
CMakeLists樣例
# vim CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(test) ### 此處的動態庫名必須和BOOST_PYTHON_MODULE()中定義的保持一致,即最後生成的庫必須名為hello.so set(SRC main.cpp) add_library(hello SHARED ${SRC}) set_target_properties(hello PROPERTIES PREFIX "") #dependencies INCLUDE(FindPkgConfig) pkg_check_modules(PYTHON REQUIRED python) include_directories(/usr/local/include ${PYTHON_INCLUDE_DIRS}) link_directories(/usr/local/lib) target_link_libraries(hello boost_python)
linux下編譯Boost庫