VS 2010 SP1如何选择boost lib文件的版本?

时间:2012-04-12 14:48:14

标签: visual-studio-2010 boost

在boost库目录下,我可以看到以下文件:

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';链接   对象好像没有调试   info C:\ source \ 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,链接器会抱怨。

Quesition > 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 个答案:

答案 0 :(得分:2)

它由boost标头中的#pragma语句确定 - 所以无论你最终包含哪个版本的标头,这都是它试图链接的lib版本。

具体来说,您可以在boost / config / auto_link.hpp中找到它,它看起来像这样:

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

奇怪的是“#pragma comment”实际上指示链接器做某事......但MS就是这样做的......

答案 1 :(得分:2)

此处定义了Boost版本:

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 \升压\ 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)