2009-11-20 47 views
11

我想構建一個依賴於Boost的應用程序。所以我將Boost 1_41_0下載到了我的Linux機器上,並按照Boost網站上的Unix變體 http://www.boost.org/doc/libs/1_41_0/more/getting_started/unix-variants.html的說明進行操作。在Linux上構建Boost - 庫名

他們基本上建議我運行./bjam install,這是我做的。構建成功完成。但是,庫名似乎不符合上述文檔中描述的Boost命名約定,以及我嘗試構建的應用程序的makefile中指定的內容。

我注意到有一堆選項可以指定給bjam,我試圖用這些選項來玩,但無論發生什麼事情,我似乎都無法完成它。我的理解是庫應該進入$ BOOST_ROOT/lib目錄。這是庫露面,但命名爲:

libboost_thread.a 
libboost_thread.so 
libboost_thread.so.1.41.0 

我希望他們將被命名libboost_thread-gcc41-MT-d-1_41_0或類似的東西。

我也嘗試./bjam --build型=完全--layout =標記,我看到:

libboost_thread.a 
libboost_thread-mt.a 
libboost_thread-mt-d.a 
libboost_thread-mt-d.so 
libboost_thread-mt-d.so.1.41.0 
libboost_thread-mt-s.a 
libboost_thread-mt-sd.a 
libboost_thread-mt.so 
libboost_thread-mt.so.1.41.0 
libboost_thread.so 
libboost_thread.so.1.41.0 

所以,我不知道我是否應該只是讓我的舞臺-L目錄?是否有任何文檔更詳細地描述了這一點?

回答

7

的名稱在1.40.0被改變 - 見release notes

構建系統

圖書館在 類Unix環境的默認命名現在匹配 系統約定,並且不 包括各種裝飾品。

他們可能忘記在構建文檔中更新這部分。

2

這裏有兩個變量。首先是「安裝」與「階段」(默認)。 「install」默認將庫和頭文件複製到目錄 -/usr/local中,然後可以刪除源代碼樹。 「stage」把庫放到「stage/lib」,你應該添加「-L/stage/lib -I」標誌。

其次是--layout =版本和--layout =系統。似乎你已經發現他們已經做了什麼,事實上,自1.40開始,系統就是默認的。入門指南沒有提到這一點,我添加了一個操作項目來更新它。理想情況下,您應該與應用程序的作者討論使用boost庫的系統命名。如果這是不可能的,那麼使用--layout = versioned構建是唯一的選擇。

1

從Boost文檔在http://www.boost.org/doc/libs/1_35_0/more/getting_started/windows.html#library-naming,慣例是:

-mt線程標記:表示該庫是在多線程啓用內置支持。沒有多線程支持的庫可以通過缺少-mt來識別。

-d ABI標記:對影響庫與其他編譯代碼的互操作性的細節進行編碼。對於每一個這樣的特徵,一個字母加入到標籤:

 
Key  Use this library when: 
s linking statically to the C++ standard library and compiler runtime support libraries. 
g using debug versions of the standard and runtime support libraries. 
y using a special debug build of Python. 
d building a debug version of your code. 
p using the STLPort standard library rather than the default one supplied with your compiler. 
n using STLPort's deprecated 「native iostreams」 feature. 

例如,如果你建立你的代碼的調試版本爲使用靜態運行時庫的調試版本,並在STLPort的標準庫「本地iostreams「模式,標籤將是:-sgdpn。如果以上都不適用,則省略ABI標籤。

+1

如何構建一個支持多線程的Boost? Boost的[安裝](http://www.boost.org/doc/libs/1_54_0/doc/html/bbv2/installation.html)沒有提及它。 – jww 2013-09-25 22:29:02

+2

建立提升時,請使用: ./b2 --build-type = complete --layout =版本號 這將生成每個庫的每個版本,包括多線程版本。 – Riot 2013-10-02 01:03:29

+1

感謝暴動。從堆棧溢出[其他討論](http://stackoverflow.com/questions/2293962/boost-libraries-in-multithreading-aware-mode)看來,Boost默認情況下是多線程的。所以如果我執行'。/ b2',那麼我就可以不用裝飾就可以進行多線程。情況並非如此嗎? – jww 2013-10-02 03:51:23