boost库 python_Boost Python学习笔记(一)

开发环境搭建

下载源码

生成编译工具

# tar axf boost_1_66_0.tar.gz

# cd boost_1_66_0

# yum install gcc gcc-c++ python-devel cmake -y

# ./bootstrap.sh

编译32位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

项目目录结构

项目初始目录结构样例

[root@fcloud example]# tree .

.

├── build

├── CMakeLists.txt

├── include

│ └── header.h

├── main.cpp

└── src

└── header.cpp

3 directories, 4 files

CMake样例(编译后将生成两个文件,一个可执行文件core,一个动态库boost.so)

cmake_minimum_required(VERSION 2.8)

project(boost)

set(CMAKE_CXX_FLAGS "-Wall -g")

### 此处的动态库名必须和BOOST_PYTHON_MODULE()中定义的保持一致,即最后生成的库必须名为boost.so

file(GLOB SRC "src/*.cpp")

add_library(boost SHARED ${SRC})

add_executable(core main.cpp)

set_target_properties(boost PROPERTIES PREFIX "")

#dependencies

INCLUDE(FindPkgConfig)

pkg_check_modules(PYTHON REQUIRED python)

include_directories(include /usr/local/include ${PYTHON_INCLUDE_DIRS})

link_directories(/usr/local/lib ${PYTHON_LIBRARY_DIRS})

target_link_libraries(boost boost_python)

target_link_libraries(core boost ${PYTHON_LIBRARIES})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值