2012-04-12 53 views
2

在boost庫目錄,我可以看到以下文件:VS 2010 SP1如何選擇boost lib文件的版本?

libboost_filesystem-VC100-MT-1_46_1.lib
libboost_filesystem-VC100-MT-1_46_1.pdb
libboost_filesystem-VC100-MT-1_47.lib
libboost_filesystem-VC100-MT-GD-1_46_1.lib
libboost_filesystem-VC100-MT-GD-1_46_1.pdb
libboost_filesystem-VC100-MT-GD-1_47.lib
libboost_filesystem-VC90-MT-1_47.lib
libboost_filesystem-vc90-mt-gd-1_47.lib

當我構建解決方案,下面的警告報道:

警告15警告LNK4099:PDB 'libboost_filesystem-VC100-MT-1_47.pdb' 不與 發現「libboost_filesystem-vc100- mt-1_47.lib(codecvt_error_category.obj)'或 'C:\ source \ Release \ libboost_filesystem-vc100-mt-1_47.pdb';聯 對象,如果沒有調試 信息C:因爲我們\源\ PROJECT1 \ libboost_filesystem-VC100-MT-1_47.lib(codecvt_error_category.obj)

正如你可以看到VS2010選擇的libboost_filesystem-vc100-mt-1_47.lib版本,唐在相同的目錄下沒有libboost_filesystem-vc100-mt-1_47.pdb,鏈接器抱怨。

問題> VS2010用什麼方法來選擇哪個版本的boost庫鏈接?

例如,如果我們有以下的庫文件,

libboost_filesystem-VC100-MT-1_46_1.lib
libboost_filesystem-VC100-MT-1_47_1.pdb
libboost_filesystem-VC100-MT-1_49_1。 lib

哪個版本將由VS2010選擇?

謝謝

回答

2

它通過在boost頭文件的#pragma聲明確定的 - 所以無論你最終包括報頭的版本,這就是LIB它將嘗試連接的是哪個版本。

具體來說,可以在升壓/配置/ auto_link.hpp發現這一點,它看起來像這樣:

# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT ".lib") 

這很奇怪的是「的#pragma評論」實際上指示鏈接器做一些事情......但是這MS是如何做到的?

2

加速版本在這裏定義:

C:\ boost1.47 \提升\ version.hpp

// 
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION 
// but as a *string* in the form "x_y[_z]" where x is the major version 
// number, y is the minor version number, and z is the patch level if not 0. 
// This is used by <config/auto_link.hpp> to select which library version to link to. 

#define BOOST_LIB_VERSION "1_47" 

C:\ boost1.49 \ boost \ version。HPP

// 
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION 
// but as a *string* in the form "x_y[_z]" where x is the major version 
// number, y is the minor version number, and z is the patch level if not 0. 
// This is used by <config/auto_link.hpp> to select which library version to link to. 

#define BOOST_LIB_VERSION "1_49" 

Boost庫名稱被如下形成:

C:\ boost1.49 \升壓\配置\ auto_link.hpp

// 
// now include the lib: 
// 
#if defined(BOOST_LIB_NAME) \ 
     && defined(BOOST_LIB_PREFIX) \ 
     && defined(BOOST_LIB_TOOLSET) \ 
     && defined(BOOST_LIB_THREAD_OPT) \ 
     && defined(BOOST_LIB_RT_OPT) \ 
     && defined(BOOST_LIB_VERSION) 
相關問題