當前位置:首頁 » 編程軟體 » boost編譯配置

boost編譯配置

發布時間: 2023-05-05 20:12:30

㈠ 如何編譯boost linux

linux平台下要編譯安裝除gcc和gcc-c++之外,還需要兩個開發庫:bzip2-devel 和python-devel,因此在安裝前應該先保證這兩個庫已經安裝:
#yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y
然後是去官網下載源碼包,按照如下步驟:
#tar xvzf boost_1_50_0.tar.gz
進入boost_1_50_0目錄:
#cd boost_1_50_0
然後是編譯安裝,boost源碼包中有配置腳本,直接用就可以:
#sh ./bootstrap.sh
Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2
Detecting Python version... 2.6
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
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://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html
接下來就是編譯,重點關注是否編譯成功:
#./b2

㈡ 如何在ubuntu下配置boost

這里有兩種安裝方法:

=============
第一種:

也是最簡單的:進入linux系統後,輸入
# apt-cache search boost
你將看到很多文件信息,你會看到其中一個文件叫 libboost-dev, 直接安裝此文件即可:
# apt-get install libboost-dev
這樣就安裝成功了。這個速度很快,是因為直接拷貝了lib文件到系統。
可以使用本文最後代碼測試安裝成功與否。

==============
第二種:
這個速度比較慢,因為需要自己編譯出lib庫。
首先下載boost庫從www.boost.org這個網站下載linux的boost庫,有2種格式,1) .bz2 2) .gz
我下的是gz結尾的。放到linux的文件系統里,這里假設為/usr/local/boost_1_52_0.tar.gz

第一步:解壓壓縮包,命令如下,(#號僅為起始標記作用,敲命令時忽略):
# cd /usr/local/
# tar -zxvf boost_1_52_0.tar.gz

第二步:解壓後得到文件夾boost_1_52_0,運行如下命令:
# cd boost_1_52_0/
# ./bootstrap.sh //這個命令類似於配好環境

第三步:運行二步命令後得到一個文件,名字是bjam,運行這個文件:
# ./bjam //這里需要十幾分鍾,完成後就代表安裝成功了。

第四步:檢驗安裝成功否:在linux下任意目錄下創建test.cpp

#include
#include
int main()
{
int a = boost::lexical_cast("123456");
std::cout << a < return 0;
}

這是一個字元串轉化為整數的簡單程序

運行命令:
# g++ test.cpp -o test
# ./test

將得到輸出結果為:123456
代表boost安裝成功,就可以盡情使用boost的美妙了!!!

㈢ 如何在XCode中配置Boost庫

話說boost在xcode5上的安裝確實很費勁,參考實驗了相當數量的文章後,終於成功在IOS模擬器上跑通了boost庫,廢話少說,上步驟

1. 下載boost.sh安裝腳本,這里選擇的是payco的安裝腳本,https://gist.github.com/payco/6880661 ,最簡單好用。也可以在csdn上我的代碼中下載,https://code.csdn.net/snippets/68017.git
2. 打開終端,su成root,命令為 sudo su,輸入密碼即可
3. 清理掉所有之前安裝的配置,尤其是在用戶目錄下的user-config.jam,必須刪除掉,之前安裝的文件也一並刪除掉,免得影響。(本人就是沒清理之前的配置,導致一直編譯不通過)
4. 把boost.sh 拷貝到/usr/local 下,運行之,會自動下載,解壓,配置,編譯boost。
5. 等待編譯安裝完畢後,顯示 Completed successfully,boost庫即安裝完畢

完成了一半,剩餘的工作就是配置xcode5,其他版本的xcode也是大同小異,沒有什麼區別的。
6. 在xcode下的target-》Building setting-> Linking-> Other Linker Flags中,添加 -lboost_system -lboost_thread,這兩項(常用的功能都包含在這2個庫中,還有其他要使用的功能,都在這里添加庫文件)

7. 在在xcode下的target-》Building setting->Search Path s 中,Header Search Path 添加/usr/local/ios/prefix/include
8. 在在xcode下的target-》Building setting->Search Paths 中,Library Search Path 添加/usr/local/ios/prefix/lib(這是給真機用的,包含arm6,arm7,arm7s等),以及/usr/local/ios/build/i386(這是給模擬器用的),基本都在一個位置上,截取一張圖好了

添加完畢之後,測試一下編譯是否成功。
在任意一個cpp文件內,添加
#include "boost/swap.hpp"
#include "boost/asio.hpp"

編譯無報錯,則順利完成boost庫在xcode5下的IOS使用編譯:)

㈣ 如何編譯&使用boost庫

1. 編譯

1.2. VS2005編譯boost_1_55_0

1.2.1. 使用vs2005的命令行執行:...\boost_1_55_0\bootstrap.bat

1.2.2. 編譯動態庫

bjam install stage --toolset=msvc-8.0 --stagedir="C:\Boost\boost_vc_80" link=shared runtime-link=shared threading=multi debug release

1.2.3. 編譯靜態庫

bjam install stage --toolset=msvc-8.0 --stagedir="D:\Boost\boost_vc_80" link=static runtime-link=static threading=multi debug release

各種參數詳解:

stage:表示只生成庫(dll和lib)

install:還會生出包含的頭文件

--toolset=msvc-8.0:指定編譯器版本,8.0為vs2005,其他VS類推。

--stagedir:指定編譯後存放的目錄

link:生成動態庫/靜態庫。動態庫(shared),靜態庫(static)

runtime-link:動態/靜態C/C++運行時庫,同樣有shared和static兩種組合方式。這樣共有4種組合方式,個人根據自己需要選擇。

threading:單/多線程,一般都是多線程程序,當然multi了。

debug/release:編譯版本,一般2個都需要。

2. 使用

使用靜態庫:

[cpp] view plain print?
//#define BOOST_ALL_DYN_LINK
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>

使用靜態庫連接時,僅需要包含的lib為:

debug版:libboost_system-vc80-mt-gd-1_55.lib等一系列包含gd的庫。

release版本:libboost_system-vc80-mt-1_55.lib等一系列不包含gd的庫。

使用動態庫鏈接:

[cpp] view plain print?
#define BOOST_ALL_DYN_LINK
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
使用動態庫鏈接時,僅需要包含的lib為:

debug版:boost_system-vc80-mt-gd-1_55.lib,同時在生成的exe加入boost_system-vc80-mt-gd-1_55.dll

release版:boost_system-vc80-mt-1_55.lib,同時在生產的exe路徑下加入boost_system-vc80-mt-1_55.dll

㈤ windows boost 32位怎麼編譯

方法1.運行腳本vsvars32.bat:
D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat
這個批處理 主要就是在運行CMD的時候先為我們設置一下環境變數(臨時的) (這個腳本中寫入的是bin, lib,include , tools的路徑信息,也可以自己配置)

方法2.設置系統環境變數:
電腦右鍵屬性-->高級環境變數-->系統環境變數選擇PATH 編輯,將以下內容復制追加:
;D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE;D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcpackages;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Windows\Microsoft.NET\Framework64\v3.5;C:\Windows\Microsoft
環境變數生效可能需要重啟計算機。

㈥ Linux下G++怎麼編譯使用Boost庫的程序

首先把Boost庫的頭文件存放到/usr/include/boost/路徑下,再把Lib文件存放到/usr/local/lib/boost/路徑下。修改/etc/profile文件,在此文件中增加如下2個環境變數:

BOOST_INCLUDE=/usr/include/boost
export BOOST_INCLUDE

BOOST_LIB=/usr/local/lib/boost
export BOOST_LIB

寫一個如下所示的cpp文件。
//samlpe.cpp
#include <iostream>
#include <string>
#include <boost/thread.hpp>

using namespace std;

void threadRoutine(void)
{
boost::xtime time;
time.nsec = 0;
time.sec = 20;
cout << "線程函數做一些事情" << endl;
boost::thread::sleep(time);
}

int main(void)
{
string str;
cout << "輸入任意字元開始創建一個線程..." << endl;
cin >> str;
boost::thread t(&threadRoutine);
t.join();
cout << "輸入任意字元結束運行..." << endl;
cin >> str;
return 0;
}

保存。使用g++編譯,命令如下所示:

g++ -o samlpe.out samlpe.cpp -I$BOOST_INCLUDE -L$BOOST_LIB -lboost_thread-gcc-mt

其中-I參數指定Boost頭文件路徑,-L參數指定Boost庫文件路徑,-l參數指定使用線程庫名。在我使用的這個版本Boost里,到/usr /local/lib/boost路徑下,可以看到有關Boost線程庫文件,比如:libboost_thread-gcc-mt.a等。注意在用-l 參數指定庫名時把磁碟文件名前面那個lib前綴去掉就可以了。

㈦ windows下boost怎樣安裝與使用說明

1. 概述

最近打算學習一下Boost庫,這里記錄一下Boost庫的安裝的方法,IDE涉及DEV C++和VS 2008。

2. 下載

直接下載鏈接:參見網頁 http://www.boost.org/users/history/version_1_46_1.html,這里的鏈接網速很慢,78MB的東西,下載了10%左右,就定住了,試了三次都是這樣,基本放棄了這個下載鏈接。
SVN下載鏈接,文件保存在「D:\Boost」下:參見網頁 http://www.boost.org/users/download/,有一定速度,下載使用了49分鍾,傳了115.99MB,版本為1.47,我看了下下載的文件夾,嚇了我一跳:文件夾大小501MB,佔用空間3.15GB。趕緊去網上查了下,有的人說對於1.46版本的Boost,如果完全編譯後,可能需要12-15GB的空間,這樣就不奇怪了,雖然還沒編譯就佔了3GB。

3. VS2008 Boost庫編譯(-vc9)

首先,編譯bjam,在命令行下,運行bootstrap.bat -vc9
然後,編譯庫。在命令行下,運櫻碼行:

bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\vc9" link=static runtime-link=shared threading=multi debug release
bjam stage --toolset=msvc-9.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\vc9" link=static runtime-link=static threading=multi debug release
編譯用了50分鍾左右,產生了303MB的文件。

4. VS2008 Boost庫配置

Tools -> Options -> Projects and Solutions -> VC++ Directories
在Library files中,增加D:\Boost\bin\vc9\lib
在Include files中,增加D:\Boost\
其中,Library的目錄就是前面編譯產生的那些庫文件保存到的位置
其中,Include的目錄隨著Boost的不同版本會不同,現在1.47版本只要指定為D:\Boost即使用SVN下載Boost的文件夾就可以了。

5. VS2008 Boost庫測試

View Code
6. DEV C++ Boost庫編譯

首先,設置gcc的環境變數。在我的電腦上點擊右鍵,選擇Properties菜單項。型鬧然後在彈出的對話框中選擇Advanced頁脊租哪,點擊Environment Variables按鈕。之後進行如下設置,選擇PATH,然後點擊Edit按鈕,在最後加上DEV-C++編譯器的路徑,如C:\Program Files\DEV-CPP\Bin,路徑之間用分號分隔。 設置完畢點擊OK按鈕保存。
然後,編譯bjam,運行bootstrap.bat -gcc
接著,編譯boost庫:

bjam stage --toolset=gcc --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\gcc" link=static runtime-link=shared threading=multi debug release
bjam stage --toolset=gcc --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="D:\Boost\bin\gcc" link=static runtime-link=static threading=multi debug release
7. DEV C++ Boost庫配置

在Toos->Compiler Options->Directories->C++ Include中,增加D:\Boost
8. DEV C++ Boost庫測試

第一種,只要包含該頭文件即可,就能使用該頭文件中的所有函數。

View Code
第二種,需要建立一個project,而不能只是編譯單個的c++文件,因為在dev c++中,只有在project中才能設置linker的參數。 建立project後,「Project"-->"Project Options"-->"Parameters"選項卡--->在linker框中添加:"-lboost_regex-mt",告訴linker在鏈接的時候,鏈接regex庫。

View Code
9. 參考文獻

Boost下載安裝編譯配置使用指南(含Windows和Linux) http://kb.cnblogs.com/a/1485890/
VS2008中編譯Boost 1.38 http://blog.csdn.net/wrx_2009/archive/2009/06/04/4242841.aspx
VS2008 Team System 安裝Boost庫 http://www.cookbus.com/show-121-1.html
boost在DevC++中的安裝過程 http://blog.csdn.net/suwei19870312/archive/2011/03/13/6246400.aspx

㈧ 安裝了多個版本vs怎麼編譯boost

boost有些庫是不用安裝的,僅需包含頭文件庫就行了。
但是有些很爽的庫(thread,regex)需要根據不同的系統做不同的調整,所以必須編譯。
編譯的流程很簡單,如果是windows操作系統,首先找到那個booststrap.bat的東西,然後在控制台下運行它,它會生成bjam.exe,然後就可以通過bjam來編譯boost庫了,在命令行下輸入bjam --help看選項。

如果嫌麻煩,可以一次將boost庫需要編譯的全部編譯了,bjam --build-type=complete,生成庫全在stage目錄下。

㈨ 如何編譯libboost

您好,這樣的:
1、當前boost最新版本為1.55,下載地址http://sourceforge.net/projects/boost/files/boost/1.55.0/
或者從官網(www.boost.org)下載最新版的BOOST源碼,經過測試,2012和2013步驟相同,這里以2012為例。
2、打開VS2012 Native Tools Command,可以從開始--Microsoft Visual Studio 2012找到:將下載的 boost_1_55_0.zip 解壓在F盤,例如 F:\boost_1_53_0,執行bootstrap.bat。
3、編譯,可以簡單的使用b2 install,也可以指定存放目錄,或者尋找網上其它幫助文章。
查看幫助可以輸入:.\b2 --help
比如要開啟多線程編譯:b2 install threading=multi
設置生成的是debug或者release
備註:如果是使用VS2013,請指定輸出庫類型,否則會缺一個lib文件:
"無法打開文件 libboost_thread_vc120_mt_sgd-1_55.lib"。
在2013時,我是使用下面的語句進行編譯:
// 如果要獲取動態庫:
bjam install stage --toolset=msvc-12.0 --stagedir="C:\Boost\boost_vc_120" link=shared runtime-link=shared threading=multi debug release
// 如果是要獲取靜態庫:

bjam install stage --toolset=msvc-12.0 --stagedir="C:\Boost\boost_vc_120" link=static runtime-link=static threading=multi debug release

其中,注意修改--toolset=msvc-12.0,將12.0修改成對應的vs版本號,12.0是VS2013的版本號。

目標地址也要修改成你所需的。

注意,不要漏了install,它會幫你把頭文件集合到一個文件夾中。
編譯過程有一個復制過程,編譯需要的時間比較長,本次編譯過程中,會在C盤根目錄下生成一個boost文件夾,然後包含include和lib文件夾,這就是我們將要使用的頭文件和庫文件。

4、編譯完了我們就使用編譯在C盤中的文件。我將它們拷貝到了F盤,
需要簡單的配置兩個地方:這里使用絕對路徑,也可以配置環境來使用。
5、然後建立了一個工程測試。 在BoostTest中新建一個控制台應用程序,下圖三個文件分別是:
1) 將要使用的boost頭文件和庫文件。 2) 解壓出的boost文件夾,就是使用這個文件夾來進行 1 -- 3步驟的。 3)BoostTest 測試工程。
#include <iostream>

#include <boost/thread/thread.hpp>
void hello()
{
std::cout << "Hello world, I'm a thread!" << std::endl;
}
int main()
{
boost::thread thrd(&hello);
thrd.join();
}
編譯測試工程, 並運行,開始boost之旅吧。

㈩ 如何編譯boost.1.60庫

64位windows平台,編譯環境是VS2005,進入Visual Studio 2005 x64 Win64 Command Prompt(單純的cmd也不一定不行,我沒試)。把bjam.exe放在boost根目錄下,進入根目錄,執行:
bjam --toolset=msvc address-model=64 --with-thread stage
bjam --toolset=msvc address-model=64 --with-date_time stage
關鍵選項:「address-model=64 」
64位Linux平台,使用gcc編譯。進入boost根目錄,執行:
./bjam --toolset=gcc --with-thread stage
./bjam --toolset=gcc --with-date_time stage
linux平台下倒是簡單,不過網上有篇文章介紹用如下命令編譯,不知道是多此一舉,還是適用於某些情況(非64位linux主機?)。
./bjam --toolset=gcc "-sBUILD=release <cxxflags>-m64" --with-thread stage
./bjam --toolset=gcc "-sBUILD=release <cxxflags>-m64" --with-date_time stage

唉。命令都很簡單,可浪費了我不少時間。usage根本沒寫,去看boost build的嘛,頁數n多不說,看完之後能否找到答案還是未知數。網上相關資料很少而且大多南轅北轍,只好一直搜索+嘗試。其實我只是想要個64位版本的庫而已,這應該不是啥稀罕的需求吧?
在windows平台下,編譯出來的是否是64位類庫,只有link 64位程序的時候才能發現。如果不是,link程序無法找到類庫中定義的函數或者類。linux不知道,因為我整出來直接就是64位了,我也懶得再找一台32位linux主機折騰了。
在1.37之後的boost,如果想要使用boost::thread庫,必須有boost::date_time庫。當然這件事情又一如既往很酷地沒有出現在容易看到的地方。而是讓你鏈接錯誤後再去玩抓蟲游戲。

熱點內容
樹莓派自帶ftp開啟 發布:2025-07-07 21:11:41 瀏覽:49
智慧樹用腳本會怎麼樣 發布:2025-07-07 21:05:48 瀏覽:514
隨機啟動腳本 發布:2025-07-05 16:10:30 瀏覽:535
微博資料庫設計 發布:2025-07-05 15:30:55 瀏覽:32
linux485 發布:2025-07-05 14:38:28 瀏覽:310
php用的軟體 發布:2025-07-05 14:06:22 瀏覽:760
沒有許可權訪問計算機 發布:2025-07-05 13:29:11 瀏覽:437
javaweb開發教程視頻教程 發布:2025-07-05 13:24:41 瀏覽:736
康師傅控流腳本破解 發布:2025-07-05 13:17:27 瀏覽:249
java的開發流程 發布:2025-07-05 12:45:11 瀏覽:696