使用boost编译时出错 [英] Error when compiling with boost

查看:354
本文介绍了使用boost编译时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了使用< boost / thread / locks.hpp> 的项目,我添加了 include 目录附加包含目录 lib 文件夹到链接器。但是当我尝试构建解决方案,错误:

I writed project which uses <boost/thread/locks.hpp>, i added include directory to Additional Include directories, and lib folder to linker. But when i try to build solution, error:


错误1错误LNK1104:无法打开文件'libboost_thread-vc100-mt-sgd-1_50 .lib'

Error 1 error LNK1104: cannot open file 'libboost_thread-vc100-mt-sgd-1_50.lib'

我在lib目录中搜索过这个文件,但在lib目录中没有这个文件名。我找到类似名称 libboost_thread-vc100-mt-gd-1_50 的文件。

I searched this file in lib directory, but no file with this name in lib directory. I found file with similar name libboost_thread-vc100-mt-gd-1_50.

我做错了?

推荐答案

您的问题似乎与这个问题。根据这里描述的链接器想要使用的库之间的唯一区别而你所拥有的库是前者链接到c ++标准库和编译器运行时支持库。我可以想出两种方法来解决这个问题:

Your problem seems to be pretty similar to the one in this question. According to the naming conventions described here the only difference between the library the linker wants to use and the library you have is that the former links statically to the c++ standard library and the compiler runtime support libraries. I can think of two ways to solve this problem:


  1. 获取链接器想要的库 br>
    a。如果您使用了boostpro安装程序:

  1. Get the library the linker wants
    a. If you used the boostpro installer:


确保您选中多线程调试,静态运行时(我会建议你标记他们所有)

Make sure you check the box for Multithreaded debug, static runtime (I would recommend you mark them all)

b。如果您自己构建库:

b. If you built the library yourself:


打开控制台窗口

将目录更改为您的提升根目录

以下命令构建所需的库:

b2 toolet = msvc-10.0 --with-thread address-model = 64 variant = debug link = static runtime-link = static runtime-debugging = on stage

(我建议使用:

b2 toolet = msvc-10.0 address-model = 64 --build-type =完成阶段


  • 您想要的图书馆

    a。使自动链接使用共享库

  • Make the linker use the library you want
    a. Make autolink use the shared libraries


    您可以定义BOOST_THREAD_DYN_LINK(仅影响线程库)或BOOST_ALL_DYN_LIB之前包含头文件(或最好在您的VC项目预处理器设置)。这将使链接器尝试使用库 boost_thread-vc100-mt-gd-1_50.lib (请注意,缺少lib-前缀)。

    You can define BOOST_THREAD_DYN_LINK (to affect only the thread library) or BOOST_ALL_DYN_LIB (to affect all the boost libraries) before the inclusion of the header files (or preferably in your VC project preprocessor settings). This would make the linker try to use the library boost_thread-vc100-mt-gd-1_50.lib (note that the lib- preffix is missing).

    b。禁用自动链接


    您可以定义BOOST_ALL_NO_LIB,然后在链接器选项中添加库的确切名称

    You can define BOOST_ALL_NO_LIB and then add the exact name of your library in your linker options


  • 这篇关于使用boost编译时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆