码迷,mamicode.com
首页 > 系统相关 > 详细

linux下编译Boost库

时间:2018-05-25 13:54:17      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:bootstra   require   .com   deb   org   code   oca   boot   pre   

下载源码

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库

标签:bootstra   require   .com   deb   org   code   oca   boot   pre   

原文地址:https://www.cnblogs.com/silvermagic/p/9087275.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!