简体   繁体   English

使用boost :: thread时的Visual Studio 2010链接器错误

[英]Visual Studio 2010 linker error when using boost::thread

I am trying to using the C++ Boost threading library in Visual Studio 2010 but get a linker error when including the thread library that requires the boost libs . 我试图在Visual Studio 2010中使用C ++ Boost线程库 ,但是在包含需要boosts库线程库时出现链接器错误。

Here is the linker error after including <boost/thread/thread.hpp> 这是包含<boost/thread/thread.hpp>之后的链接器错误

Error 2 error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ) 错误2错误LNK2001:无法解析的外部符号“类boost :: system :: error_category const&__cdecl boost :: system :: generic_category(void)”(?generic_category @ system @ boost @@ YAAEBVerror_category @ 12 @ XZ)

After some research I got the impression that this error can be caused by a bad installation or installation of the wrong build version so here is the installation steps I took. 经过研究后,我得到的印象是该错误可能是由于安装不正确或安装版本号错误引起的,因此这里是我执行的安装步骤。

  1. Downloaded boost_1_51_setup.exe from http://www.boostpro.com/download/ http://www.boostpro.com/download/下载boost_1_51_setup.exe

  2. Ran the installer selecting all the tick boxes on the threading and library page 运行安装程序,选择“线程和库”页面上的所有复选框

  3. Allowed the installer to add an environment variable to the OS path 允许安装程序将环境变量添加到OS路径

  4. In the visual studio project added C:\\Program Files\\boost\\boost_1_51 to additional dependencies in C/C++-> General 在Visual Studio项目中,将C:\\Program Files\\boost\\boost_1_51添加到C / C ++-> General中的其他依赖项

  5. Finally added C:\\Program Files\\boost\\boost_1_51\\lib to additional libraries in Linker->General 最后将C:\\Program Files\\boost\\boost_1_51\\lib添加到Linker-> General中的其他库中

I have triple checked all the path, all seem fine. 我对所有路径进行了三重检查,一切似乎都很好。 And read the boost getting started page several time... I can't find what I'm missing. 并多次阅读Boost入门页面...我找不到我想要的东西。

I am running windows 8 x64, although I don't think this makes a difference. 我正在运行Windows 8 x64,尽管我认为这没有什么不同。

Right click your project in the solution explorer and click properties. 在解决方案资源管理器中右键单击您的项目,然后单击属性。

Go to the VC++ directories tab and add the boost libraries do the 'Library Directories'. 转到VC ++目录选项卡,然后添加boost库来执行“库目录”。

You could also add the include folders to the 'Include Directories' section. 您也可以将包含文件夹添加到“包含目录”部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM