boost1.59編譯安裝(可以完全安裝,也可定制安裝--buildtype=complete,link=static)


 

1、下載:

       網址:http://sourceforge.net/projects/boost/files/boost/1.59.0/

       選擇:boost_1_59_0.7z或者boost_1_59_0.zip (Windows 8.1企業版操作系統);

                   boost_1_59_0.tar.bz2  ( Linux內核操作系統——Ubuntu 14.04(編譯器使用自帶的GCC 4.8.2))。

2、編譯:

  • 2.1 Ubuntu 14.04操作系統編譯安裝boost 1.59.0:

    2.1.1 快速安裝Boost:

    在Linux內核的操作系統下安裝boost 1.59.0很容易,最簡單的方式是在Boost解壓縮后的目錄下直接執行命令:

   ./bootstrap.sh

   ./b2 install

    第一條命令語句booststrap.sh是編譯前的配置工作,第二條命令b2開始真正的編譯並安裝Boost。由於未指定額外選項,Boost將編譯Release版本的庫文件,把頭文件安裝到/usr/local/include,庫文件安裝到/usr/local/lib。

        2.1.2 完整安裝Boost:

    完整編譯Boost,使用buildtype選項指定編譯類型(如不指定默認使用release模式),在bootstrap.sh之后執行如下命令:

   ./b2 --buildtype=complete install

          這樣將開始對Boost的完整編譯,安裝所有調試版、發行版的靜態庫和動態庫。

         2.1.3  定制安裝Boost:

          完整編譯Boost費時費力,在實際開發中這些庫也不會都用到,因此,Boost也允許用戶自行選擇要編譯的庫。執行命令:

    ./b2 --show-libraries

          可查看所有必須編譯才能使用的庫。

          在完全編譯的基礎上,可使用--with或者--without選項打開或者關閉某個庫的編譯,如:

    ./b2 --with-date_time --buildtype=complete install

         將僅編譯安裝date_time庫。

         一般可使用如下安裝命令:

   sudo ./b2 link=static install       #編譯安裝所有靜態庫

 

  • 2.2 Windows 8.1操作系統安裝配置boost 1.59.0:

         直接在官網:http://sourceforge.net/projects/boost/files/boost-binaries/1.59.0/ ,下載:boost_1_59_0-msvc-12.0-64.exe,然后解壓配置即可。

        boost_1_59_0-msvc-12.0-64.exe    Visual Studio 2013     64位版本的boost庫。

 

 

error 解決:

一:使用需要python庫

否則出現如下error:

./boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory
compilation terminated.

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -march=i686 -pthread -fPIC -m32 -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE -DNDEBUG -I"." -I"/usr/include/python2.7" -c -o "bin.v2/libs/python/build/gcc-5.4.0/release/threading-multi/object/function_doc_signature.o" "libs/python/src/object/function_doc_signature.cpp"

...failed gcc.compile.c++ bin.v2/libs/python/build/gcc-5.4.0/release/threading-multi/object/function_doc_signature.o...

..failed updating 58 targets...
...skipped 12 targets...
...updated 11810 targets...

 

使用

sudo apt-get install python-dev

 

 

bzlib.h: No such file or directory

 

 理論上,本文適用於boost的各個版本,尤其是最新版本1.48.0;適用於各種C++編譯器,如VC6.0(部分庫不支持),VS2003,VS2005,VS2008,VS2010,gcc,C++ Builder等。

1.下載boost源文件

http://www.boost.org/users/download/ 

2.安裝

cd /home/boost_1_48_0/
首先需要編譯bjam: ./bootstrap.sh --prefix=/home/boost-1.48.0/sdk/  設置庫安裝路徑

通過bjam編碼boost庫: ./bjam  install


3.設置環境變量
        在/etc/profile.d新建可執行文件boost.sh,添加文件內容:

#!/bin/sh
BOOST_INCLUDE=/home/boost-1.48.0/sdk/include/boost 
BOOST_LIB==/home/boost-1.48.0/sdk/lib
export BOOST_INCLUDE BOOST_LIB 


命令行執行:source /etc/profile.d/boost.sh
        以后在編譯程序時,只需要用:-I$BOOST_INCLUDE -L$BOOST_LIB 即可,還要使用-l指定了鏈接庫。

 

然后, /etc/ld.so.conf 文件添加so庫的環境變量 /home/boost-1.48.0/sdk/lib(主要關鍵問題)

修改完成后,通過ldconfig命令進行重啟



4.遇到的問題及解決方案
安裝過程出現很多和bz及Python庫相關的錯誤,解決方案如下

命令方式

sudo apt-get install libbz2-dev    yum install python-dev
或
yum install libbz2-dev   yum install python-dev

圖像界面方式

   點擊Applications---->Add/Remove Software 去安裝這個包文件


PS 安裝過程中的錯誤:

libs/iostreams/src/bzip2.cpp:20:56: error: bzlib.h: 沒有那個文件或目錄
libs/iostreams/src/bzip2.cpp:31: error: ‘BZ_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:32: error: ‘BZ_RUN_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:33: error: ‘BZ_FLUSH_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:34: error: ‘BZ_FINISH_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:35: error: ‘BZ_STREAM_END’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:36: error: ‘BZ_SEQUENCE_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:37: error: ‘BZ_PARAM_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:38: error: ‘BZ_MEM_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:39: error: ‘BZ_DATA_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:40: error: ‘BZ_DATA_ERROR_MAGIC’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:41: error: ‘BZ_IO_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:42: error: ‘BZ_UNEXPECTED_EOF’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:43: error: ‘BZ_OUTBUFF_FULL’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:44: error: ‘BZ_CONFIG_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:48: error: ‘BZ_FINISH’ was not declared in this scope
//mostly like above....

 

 

./boost/python/detail/wrap_python.hpp:50:23: error: pyconfig.h: No such file or directory
./boost/python/detail/wrap_python.hpp:75:24: error: patchlevel.h: No such file or directory
./boost/python/detail/wrap_python.hpp:78:2: error: #error Python 2.2 or higher is required for this version of Boost.Python.
./boost/python/detail/wrap_python.hpp:142:21: error: Python.h: No such file or directory
./boost/python/instance_holder.hpp:34: error: ‘PyObject’ has not been declared
./boost/python/instance_holder.hpp:41: error: expected ‘;’ before ‘(’ token
./boost/python/instance_holder.hpp:45: error: ‘PyObject’ has not been declared
./boost/python/detail/wrapper_base.hpp:21: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:23: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:30: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:34: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:43: error: ‘PyObject’ has not been declared
./boost/python/detail/wrapper_base.hpp:44: error: ISO C++ forbids declaration of ‘PyObject’ with no type
./boost/python/detail/wrapper_base.hpp:44: error: ‘PyObject’ is neither function nor member function; cannot be declared friend

windows下編譯安裝boost.

先生成bjam,要在vs附帶的命令行下執行才可以,在cmd下運行bat可能會卡主不動

bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="E:\boost_1_49" link=static runtime-link=static threading=multi debug release

默認為32位版本,編譯成64位:

bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="E:\boost_1_49_new" link=static runtime-link=static threading=multi address-model=64 debug release

 
http://www.cnblogs.com/oracleloyal/p/6060779.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM