2

在 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_46_1.pdb -vc100-mt-gd-1_47.lib
libboost_filesystem-vc90-mt-1_47.lib
libboost_filesystem-vc90-mt-gd-1_47.lib

当我构建解决方案时,会报告以下警告:

警告 15 警告 LNK4099:在“libboost_filesystem-vc100-mt-1_47.lib(codecvt_error_category.obj)”或“C:\source\Release\libboost_filesystem-vc100”中找不到 PDB“libboost_filesystem-vc100-mt-1_47.pdb” -mt-1_47.pdb'; 链接对象好像没有调试信息 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同一目录下的 ,所以链接器会报错。

问题 > 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会选择哪个版本?

谢谢

4

2 回答 2

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的做法......

于 2012-04-12T15:00:16.477 回答
2

Boost 版本在这里定义:

C:\boost1.47\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_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\boost\config\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)
于 2012-04-12T15:39:38.060 回答