2012-07-08 97 views
4

我编写了使用<boost/thread/locks.hpp>的项目,我将include目录添加到Additional Include directorieslib文件夹链接器。但是,当我尝试建立的解决方案,错误:使用boost编译时出错

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

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

我做错了什么?

+0

我想你已经安装了库或建立他们纳入到你的项目? – mathematician1975 2012-07-08 16:06:49

+0

我建立了他们的引导http://www.boost.org/doc/libs/1_50_0/doc/html/bbv2/installation.html – Robert 2012-07-08 16:08:01

+0

您使用的是什么操作系统和编译器? – mathematician1975 2012-07-08 16:08:20

回答

7

您的问题似乎是非常相似的一个在this question。根据命名规则描述here链接器要使用库,并且你有磁带库之间的唯一区别是,前者静态链接到C++标准库和编译器运行支持库。我能想到的两种方法来解决这个问题:

  1. 获取连接要
    一个图书馆。如果您使用了boostpro安装程序:

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

    b。如果自己建库:

    Open a console window
    Change directory to your boost root
    The following command builds the required library:
    b2 toolset=msvc-10.0 --with-thread address-model=64 variant=debug link=static runtime-link=static runtime-debugging=on stage
    (I would recommend using:
    b2 toolset=msvc-10.0 address-model=64 --build-type=complete stage)

  2. 让链接器可以使用库您想
    一个。使自动链接使用共享库

    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。禁用自动链接

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

+0

你的意思是这条命令: 1)bootstrap.bat 2)B2安装--prefix = PREFIX运行时链接=静态 ? – Eyalk 2012-12-15 17:59:54

+0

@Eyalk由罗伯特,你似乎被引用的评论的链接页面介绍了Boost.Build二进制文件的安装。在这一步中,你不应该添加'runtime-link = static'。一旦你安装了Boost.Build,你需要构建Boost库。在这个步骤中,您需要将其添加到您的命令中。我会尝试编辑答案以使其更清楚。 – 2012-12-15 19:05:18