尝试链接 Boost 1.52 线程
Trying to link Boost 1.52 thread
我正在尝试编译我的程序,但它根本不会链接。我已经指定了 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 专业版,我使用以下选项编译了 boost
bjam --build-type=complete --toolset=msvc10.0 address-model=64 architecture=x86 variant=debug,release threading=multi link=static runtime-link=static
有人可以告诉我出了什么问题吗?
更新:
更改为 boost 1.51 后,它摆脱了 7 个链接器错误中的 8 个,但这个仍然存在
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 的问题。稍后会更新。
我之前遇到过同样的问题:我使用直接运行引导.bat的默认参数构建 boost lib。
如果在项目中使用 boost::system,则应使用并指定 x86 或 x64 版本的 boost::system lib。
您可以使用此 BAT 重新编译 Boost Lib,保存这些到 boost 根文件夹并在 CMD 窗口中运行它(不要双击!
call "%VS140COMNTOOLS%....VCvcvarsall.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/
,它没有正确自动链接。
Include path is boost152/ only
Library path is boost152/stage/lib
正确的目录添加到链接器属性中。
阅读这篇文章以了解更多详情Boost 链接器错误:未解析的外部符号"class boost::system::error_category const & __cdecl boost::system::get_system_category(void)"
此外,还必须将此路径添加到链接器添加目录中:
$(BOOST_ROOT)\bin.v2\libs\thread\build\msvc-xx.0\release\address-model-64\link-static\threading-multi
其中 xx 是您的 Visual Studio 版本
这两个定义弄乱了我的链接器,抛出了一个漂亮的"LNK2001:未解析的外部符号"错误。那么在你的代码中有某个地方吗?
//#define BOOST_FILESYSTEM_NO_DEPRECATED
//#define BOOST_FILESYSTEM_NO_LIB
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- boost::文件系统::recursive_directory_iterator多线程安全
- 将更高的优先级设置为 boost::asio 线程处理进程
- 如何正确取消析构函数中的 Boost deadline_timer(在多线程环境中)?
- boost信号和插槽在不同的线程中不工作(使用boost::asio::io_service)
- BOOST线程:线程还是进程
- C++boost,等待来自不同线程的varinit
- 如何解决传递给boost线程的函数中的歧义
- 调用boost.asio的异步函数时,线程是什么时候创建的
- cpp 为什么 boost::线程内部的循环不遍历所有值并且推送相同的值?
- 如何使用boost.thread运行多个接收器,每个线程应该分配给每个接收器?
- 使用Boost将单线线程转换为多线程
- C 带有两个线程的boost async_read vs
- 重写多线程事件驱动的C 程序以使用单线程Boost :: Asio
- 多个boost io_service在单独的线程上用于多个网卡
- 在具有许多内核的计算机上,使用 Boost ASIO 只能使用 1 个线程
- 我们是否需要每个线程多个io_service用于具有单个接受器的线程 boost::asio 服务器
- 如何实现动态线程 Boost::Barrier
- 线程+ boost::函数中的getline访问冲突
- 使用c++线程/ boost线程的有效方法