boost编译python模块

转载:https://www.jianshu.com/p/7c49fc1d5780

 

1. Boost 下载

链接:https://dl.bintray.com/boostorg/release/
这里下载了boost_1_69_0.7z;


2. 解压,进入编译环境

解压缩后,通过VS Build tools(VS 的开发人员命令提示符) (或通过 VS-工具-VisualStudio命令提示)进入 boost库 ,进行编译的步骤:
將目录cd到 boost_1_69_0 下执行


3. python首先确保 python 是否存在

键入 python(或者 where python) ,确保可以执行到需要编译的python版本;

c:\boost_1_69_0>where python
C:\Python37\python.exe

4. 然后执行 bootstrap.bat

4.1 选择参数

可选 需要编译的编译器版本;
Visual Studio 2012 : vc11
Visual Studio 2013 : vc12
Visual Studio 2015 : vc14
今天需要vc110版本 ,于是 我们使用 vc11即可以更改默认选项,如编译v110版本;
bootstrap.bat

bootstrap.bat vc11


4.2 执行 bootstrap.bat 例子:

c:\boost_1_69_0>bootstrap.bat vc11
Building Boost.Build engine

Bootstrapping is done. To build, run:

    .\b2

To adjust configuration, edit 'project-config.jam'.
Further information:

    - Command line help:
    .\b2 --help

    - Getting started guide:
    http://boost.org/more/getting_started/windows.html

    - Boost.Build documentation:
    http://www.boost.org/build/doc/html/index.html


4.3 文件查看

执行 bootstrap.bat
成功执行后,会在boost根目录下生成bootstrap.logb2.exebjam.exe
其中可查看 bootstrap.log 查看运行结果;
bjam.exeb2.exe两个作用一样,
bjam.exe对应的是老版本,b2bjam的升级版本。


5. 编译boost.python:

b2 toolset=msvc-11.0 --with-python

5.1 可选参数:

--toolset=msvc-11.0
指编译器为vc110的;
--with-python
只编译指定的库,如输入--with-python就只编译python库了
link
生成动态链接库(=static)/静态链接库(=shared)
runtime-link
动态/静态链接C++运行库,有shared和static两种方式
threading=multi
单/多线程编译,一般写多线程,直接指定为multi
--build-type=complete
编译所有版本


5.2 可以通过 b2 --help 查看更多参数;
例子:

c:\boost_1_69_0>b2 --help
Boost.Build 2018.02-git

Usage:

  b2 [options] [properties] [install|stage]

(此处省略...)
  --with-<library>        Build and install the specified <library>. If this
                          option is used, only libraries specified using this
                          option will be built.

Properties:

  toolset=toolset         Indicate the toolset to build with.

  link=static|shared      Whether to build static or shared libraries

  threading=single|multi  Whether to build single or multithreaded binaries

(此处省略...)

6. 查看编译结果:

编译的过程会比较长,最后会在boost目录下面生成两个文件夹
stage: 对应的lib和dll文件
bin.v2: 编译时的中间文件,可以直接删除掉
可查看到已经编译好的python37 boost库;

boost_1_69_0/stage/lib$ ls -lrt
-rw-r--r-- 1 26583808 四月 25 15:18 libboost_python37-vc110-mt-gd-x32-1_69.lib
-rw-r--r-- 1  6258968 四月 25 15:18 libboost_numpy37-vc110-mt-gd-x32-1_69.lib
-rw-r--r-- 1  6121450 四月 25 15:19 libboost_python37-vc110-mt-x32-1_69.lib
-rw-r--r-- 1   830718 四月 25 15:20 libboost_numpy37-vc110-mt-x32-1_69.lib
-rw-r--r-- 1 31016626 四月 25 15:21 libboost_python37-vc110-mt-gd-x64-1_69.lib
-rw-r--r-- 1  6717140 四月 25 15:21 libboost_numpy37-vc110-mt-gd-x64-1_69.lib
-rw-r--r-- 1  7392556 四月 25 15:22 libboost_python37-vc110-mt-x64-1_69.lib
-rw-r--r-- 1   943414 四月 25 15:23 libboost_numpy37-vc110-mt-x64-1_69.lib

 

0人点赞

 

随笔

 



作者:Air徵羽
链接:https://www.jianshu.com/p/7c49fc1d5780
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值