尝试链接Boost 1.52线程 [英] Trying to link Boost 1.52 thread
问题描述
我试图编译我的程序,但它不会链接。我已经指定了boost lib文件的路径,链接器仍然抱怨。这是我得到的链接错误:
1> Edproj.obj:error LNK2001:unresolved external symbolclass 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 symbolclass boost :: system :: error_category const& __cdecl boost :: system :: generic_category(void)(?generic_category @ system @ boost @@ YAABVerror_category @ 12 @ XZ)
1> Edproj.obj:error LNK2001:未解析的外部符号public:__ thiscall boost :: detail :: thread_data_base ::〜thread_data_base(void)(?? 1thread_data_base @ detail @ boost @@ UAE @ XZ)
1> Edproj.obj:error LNK2001:未解析的外部符号void __cdecl boost :: throw_exception(class std :: exception const&)(?throw_exception @ boost @@ YAXABVexception @ std @@@ Z)
1> Edproj.obj:error LNK2001:unresolved外部符号public:void __thiscall boost :: thread :: detach(void)(?detach @ thread @ boost @@ QAEXXZ)
1> Edproj.obj:error LNK2001:unresolved external symbolpublic:void __thiscall boost :: thread :: join(void)(?join @ thread @ boost @@ QAEXXZ)
1> Edproj.obj:error LNK2001:未解析的外部符号private:void __thiscall boost :: thread :: start_thread (void)(?start_thread @ thread @ boost @@ AAEXXZ)
1> Edproj.obj:error LNK2001:未解析的外部符号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>链接到lib文件:libboost_thread-vc100-mt-s-1_52.lib
1>链接到lib文件:libboost_date_time-vc100-mt-s-1_52.lib
1>链接到lib文件:libboost_system-vc100-mt-s-1_52.lib
1>链接到lib文件:libboost_chrono-vc100-mt-s-1_52.lib
更多信息: p>
我运行的是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
有人可以告诉我有什么错误吗?
更新: p>
更改为boost 1.51后,其中的8个链接器错误中的7个被删除了,但是这个仍然是持久的
错误LNK2001:未解析的外部符号void __cdecl boost :: throw_exception(class std :: exception const&)(?throw_exception @ boost @@ YAXABVexception @ std @@@ Z)
我没有得到这里的情况。这一个是从boostpro 32位安装程序。它不能与我的源文件有什么关系吗?
更新:
这个问题为boost 1.51。出现在属性页>> C / C ++ >>代码生成>>启用C ++异常为我关闭。
确定。我将尝试看看相同的设置是否解决了提升1.52的问题。
我有同样的问题:我使用默认参数构建boost库,运行 bootstrap。
如果您在项目中使用 boost :: system ,您应该使用并指定x86或x64版本的boost :: system lib。你可以使用这个bat重新编译boost lib,保存这些文件到boost文件夹并在CMD窗口运行(不要双击! :
请致电%VS140COMNTOOLS%.. \..\VC\vcvarsall.batx86
cd boost_1_60_0
call bootstrap.bat
rem大多数库可以是静态库
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 /
I am trying to compile my program but it wouldn't link at all. I have specified the path to the boost lib files and the linker still complain. Here's the linking error I got:
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 returns
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
More info:
I am running a 64-bit Windows 8 Pro and I compiled boost with the following option
bjam --build-type=complete --toolset=msvc10.0 address-model=64 architecture=x86 variant=debug,release threading=multi link=static runtime-link=static
Can someone tell me what is wrong?
Update:
After changing to boost 1.51 it got rid 7 out of 8 of those linker errors but this one is still persistent
error LNK2001: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@Z)
I don't get what is going on here. This one is from boostpro 32 bit installer. It couldn't have something to do with my source file right?
Update :
Ok I have solved this problem for boost 1.51. Turns out in the Property Pages >> C/C++ >> Code Generation >> Enable C++ Exceptions was turn off for me.
OK. I will attempt to see if the same settings solve the problem for boost 1.52. Will update later.
I had the same problem before: I build boost lib with default parameters which run bootstrap.bat directly.
if you use boost::system in your project, you should use and appoint x86 or x64 version of boost::system lib.
you can recompile boost lib with this bat, save these to boost root folder and run it in CMD windows(don't double click!):
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
for more details you can see this article: https://studiofreya.com/2015/12/19/how-to-build-boost-1-60-with-visual-studio-2015/
这篇关于尝试链接Boost 1.52线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!