mac boost 安装

源码编译安装:

boost安装官网

  1. 下载Boost源码
  2. 解压放在任意目录,例如/usr/local/boost_1_63_0
  3. ./bootstrap.sh

会在当前目录下生成一个配置文件project-config.jam, 一般可以自动找到python的位置(正常情况下)。默认安装的位置是/usr/local,包括头文件默认路径/usr/local/include和库的默认路径/usr/local/lib。
也可以指定
./bootstrap.sh --with-python=/Users/gpf/soft/anaconda2/bin/python --with-python-version=2.7 --with-python-root=/Users/gpf/soft/anaconda2/lib/python27 --prefix=/usr/local

project-config.jam:

  1 # Boost.Build Configuration
  2 # Automatically generated by bootstrap.sh
  3
  4 import option ;
  5 import feature ;
  6
  7 # Compiler configuration. This definition will be used unless
  8 # you already have defined some toolsets in your user-config.jam
  9 # file.
 10 if ! darwin in [ feature.values <toolset> ]
 11 {
 12     using darwin ;
 13 }
 14
 15 project : default-build <toolset>darwin ;
 16
 17 # Python configuration
 18 import python ;
 19 if ! [ python.configured ]
 20 {
 21     using python : 2.7 : /Users/gpf/soft/anaconda2 ;
 22 }
 23
 24 # List of --with-<library> and --without-<library>
 25 # options. If left empty, all libraries will be built.
 26 # Options specified on the command line completely
 27 # override this variable.
 28 libraries =  ;
 29
 30 # These settings are equivalent to corresponding command-line
 31 # options.
 32 option.set prefix : /usr/local ;
 33 option.set exec-prefix : /usr/local ;
 34 option.set libdir : /usr/local/lib ;
 35 option.set includedir : /usr/local/include ;
 36
 37 # Stop on first error
 38 option.set keep-going : false ;
  1. ./b2 headers
  2. ./b2

./b2 仅仅是编译,生成相应的库文件。在当前的stage/lib目录下。头文件在boost目录下。并不会安装在之前配置的路径中。
如果安装需要指定./b2 install
不指定参数默认只会build c++ libraries, 通过指定-a --with=all,安装所有的boost.build。(包括boost.python)
./b2 --with-python 仅仅是编译python(caffe需要安装所有)

./b2 install clean 清除刚才按照到 /usr/local目录下的东西
./b2 clean 清除安装在当前目录stage下的库

boost.python官网安装说明
注:任何软件的安装都可以参照软件的官网,官网都有详细的说明,比其他的博客靠谱。
博客:
https://blog.csdn.net/qq_31720329/article/details/78184262

手动链接库:(上文的./b2 install ,就是编译完成后进行链接。./b2 install clean就是清除链接。)

sudo ln -s /Users/gpf/soft/boost_1_70_0/boost  /usr/local/include/boost
sudo find $PWD/lib/*.a -type f -exec ln -s {} /usr/local/lib \;
sudo find $PWD/lib/*.dylib -type f -exec ln -s {} /usr/local/lib/ \;

连接头文件以及动态连接库和静态连接库。

一般情况下,自己安装软件的话,一是直接将安装路径指定到/usr/local下,二是安装在别的目录,需要编译完成后,手动连接头文件,静态以及动态连接库

rf:
https://blog.csdn.net/Doubao93/article/details/80176537

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容