试图链接Boost 1.52线程

时间:2013-02-03 16:03:16

标签: c++ visual-c++ compiler-errors boost-thread visual-c++-2010

我正在尝试编译我的程序但它根本不会链接。我已经指定了boost lib文件的路径,链接器仍然抱怨。这是我得到的链接错误:

1>Edproj.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::detail::thread_data_base::~thread_data_base(void)" (??1thread_data_base@detail@boost@@UAE@XZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@Z)
1>Edproj.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::detach(void)" (?detach@thread@boost@@QAEXXZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::join(void)" (?join@thread@boost@@QAEXXZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::thread::start_thread(void)" (?start_thread@thread@boost@@AAEXXZ)
1>Edproj.obj : error LNK2001: unresolved external symbol "bool __cdecl boost::this_thread::interruptible_wait(void *,struct boost::detail::timeout)" (?interruptible_wait@this_thread@boost@@YA_NPAXUtimeout@detail@2@@Z)

BOOST_LIB_DIAGNOSTIC返回

1>  Linking to lib file: libboost_thread-vc100-mt-s-1_52.lib
1>  Linking to lib file: libboost_date_time-vc100-mt-s-1_52.lib
1>  Linking to lib file: libboost_system-vc100-mt-s-1_52.lib
1>  Linking to lib file: libboost_chrono-vc100-mt-s-1_52.lib

更多信息:

我正在运行64位Windows 8 Pro,并使用以下选项编译了boost

bjam --build-type=complete --toolset=msvc10.0 address-model=64 architecture=x86 variant=debug,release threading=multi link=static runtime-link=static

有人可以告诉我出了什么问题吗?

更新

更改为提升1.51后,它排除了8个链接器错误中的7个,但这个仍然存在

error LNK2001: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@Z)

我不知道这里发生了什么。这个来自boostpro 32位安装程序。它不能与我的源文件有关吗?

更新:

好的我已经为boost 1.51解决了这个问题。在物业页>>中结果C / C ++>>代码生成>>启用C ++例外已关闭。

行。我将尝试查看相同的设置是否解决了boost 1.52的问题。稍后会更新。

4 个答案:

答案 0 :(得分:1)

之前我遇到过同样的问题:我使用默认参数构建boost lib,直接运行 bootstrap.bat

如果在项目中使用 boost :: system ,则应使用并指定x86或x64版本的boost :: system lib。

你可以用这个蝙蝠重新编译boost lib,保存这些以提升根文件夹并在CMD窗口中运行它(不要双击!):

call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86

cd boost_1_60_0
call bootstrap.bat

rem Most libraries can be static libs
b2 -j8 toolset=msvc-14.0 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64
b2 -j8 toolset=msvc-14.0 address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32

pause

有关详细信息,请参阅此文章: https://studiofreya.com/2015/12/19/how-to-build-boost-1-60-with-visual-studio-2015/

答案 1 :(得分:0)

确保将正确的目录添加到链接器属性中。

阅读这篇文章了解更多细节 Boost linker error: Unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::get_system_category(void)"

此外,您必须将此路径添加到链接器添加目录中:

$(BOOST_ROOT)\ bin.v2 \库\螺纹\构建\ MSVC-xx.0 \释放\地址模型-64 \链路静电\线程的多

其中xx是您的visual studio版本

答案 2 :(得分:0)

感谢我看起来没有正确的自动链接。

Include path is boost152/ only
Library path is boost152/stage/lib

答案 3 :(得分:0)

下面这两个定义搞乱了我的链接器,抛出一个漂亮的“LNK2001:未解析的外部符号”错误。你的代码中有什么地方吗?

//#define BOOST_FILESYSTEM_NO_DEPRECATED
//#define BOOST_FILESYSTEM_NO_LIB