VS2010 boost 使用问题一例

最近有一个VS2010的工程用到了boost库,编译的时候报下面的错误:

>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-s-1_52.lib'

到boost库目录: ~boost_1_52_0\stage\lib 下一看,果然没有这个库,只有 libboost_thread-vc100-mt-gd-1_52.lib 与 libboost_thread-vc100-mt-1_52.lib。

那这个 'libboost_thread-vc100-mt-s-1_52.lib' 跟libboost_thread-vc100-mt-1_52.lib 有何差别呢?

-s

ABI tag: encodes details that affect the library's interoperability with other compiled code. For each such feature, a single letter is added to the tag:

Key Use this library when: Boost.Build option
s linking statically to the C++ standard library and compiler runtime support libraries. runtime-link=static
g using debug versions of the standard and runtime support libraries. runtime-debugging=on
y using a special debug build of Python. python-debugging=on
d building a debug version of your code.7 variant=debug
p using the STLPort standard library rather than the default one supplied with your compiler. stdlib=stlport

For example, if you build a debug version of your code for use with debug versions of the static runtime library and the STLPort standard library in “native iostreams” mode, the tag would be:-sgdpn. If none of the above apply, the ABI tag is ommitted.

原来,-s 代表 “runtime-link-static",我的工程是用这种方式使用boost库的,因此需要'libboost_thread-vc100-mt-s-1_52.lib'

于是重新编译boost库,用下面的编译命令:

b2 --build-dir=c:\boost-build --build-type=complete msvc stage link=static

你可能感兴趣的:(VS2010)