现在的位置: 首页 > 综合 > 正文

Boost环境配置及遇到的问题解决方案

2014年01月26日 ⁄ 综合 ⁄ 共 1794字 ⁄ 字号 评论关闭

1.模块/工具简介

Boost库是一个跨平台,开源并且完全免费的C++库,内容涵盖字符串处理、正则表达式、容器与数据结构、并发编程、函数式编程、泛型编程、设计模式实现等许多领域,使得实际的开发更加灵活和高效。(下载最新版的Boost库http://www.boost.org/


2.系统要求

Windows xp以上


3.部署步骤
(1)选择下载Boost库Windows版的安装包,解压至硬盘任意目录(建议硬盘根目录),下面用$BOOSTDIR表示boost的存放目录
(2)在解压的文件夹中找到bootstrap.bat并运行,生成bjam的可执行程序,运行即可
(3)编译完成后会生成bin.v2和stage子目录,里面包含了生成的*.lib库文件

(4)配置vs环境,创建测试项目test,工具栏项目->右键->test属性->配置属性->C/C++->常规->附加包含目录中添加$BOOSTDIR路径(C:\boost_1_54_0;),在链接器->常规->附加库目录中添加$BOOSTDIR\stage\libs(C:\boost_1_54_0\stage\lib\*.lib),应用并确定,boost库在win32环境下就部署成功了!


4.可能遇到的问题

(1)LINK : fatal error LNK1104: cannot open file '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-type=complete msvc stage link=static

(2)Already defined in libcmt.lib
解决方案参加上一篇文章

附:VS2010 静态链接 Boost 函数库的配置方法:
打开项目属性->配置属性->C/C++->代码生成,选择“运行库”为“多线程 (/MT)”(如选择“多线程 DLL (/MD)”,则为动态链接 Boost 库)。


(3)想改变编译配置的话,在boost_1_54_0\tools\build\v2 中的 user-config.jam文件,bootstrap.bat和bjam实际都是在这个目录下生成的

抱歉!评论已关闭.