c – boost :: thread build error(无法链接lib \u0026\u0026未解析的外部)

栏目: C++ · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/3164268/boostthread-build-error-unable-to-link-lib-unresolved-external

我试图在VS 2008中遵循Boost :: Thread(ver 1.4-3)的简单教程:

#include <boost/thread/thread.hpp>

void Func()
{
    // Do something
}

void main()
{
    boost::thread _thrd(&Func);
    _thrd.join();
    ....
}

在编译期间它会产生此错误:

Error 1 fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-gd-1_43.lib' CConsole

我必须通过添加#define BOOST_ALL_NO_LIB来解决这个问题.

但是,它给了我另一个错误:

Error 3 fatal error LNK1120: 2 unresolved externals 
C:\xx\Documents\Visual Studio 2008\Projects\CConsole\Debug\CConsole.exe


Error 1 error LNK2019: unresolved external symbol "public: __thiscall boost::thread::~thread(void)" (??1thread@boost@@QAE@XZ) referenced in function _wmain CConsole.obj


Error 2 error LNK2019: unresolved external symbol "private: void __thiscall boost::thread::start_thread(void)" (?start_thread@thread@boost@@AAEXXZ) referenced in function "public: __thiscall boost::thread::thread<void (__cdecl*)(void)>(void (__cdecl*)(void),struct boost::thread::dummy *)" (??$?0P6AXXZ@thread@boost@@QAE@P6AXXZPAUdummy@01@@Z) CConsole.obj

有谁知道如何解决这个问题?

谢谢.

我认为比“阅读F * cking手册”更深入的答案可能会有所帮助!

这种链接错误是您尝试链接不兼容的Boost库的线索.

当我错误地构建一个32位Boost线程库时,我认为我正在构建一个64位库时,我得到了这个.花了一段时间才弄明白,当你说–address-model = 64作为bjam命令行参数时,你犯了一个微妙的错误. address-model参数不能包含 – 前缀.不幸的是,当bjam看到错误的语法时,它不会通知您.

您可以使用dumpbin程序检查库提供的符号,以及链接器所说的未解析的符号.我发现库符号用__thiscall而不是__cdecl修饰.这是架构不匹配的尖叫好线索. Microsoft编译器使用__thiscall函数调用协议进行32位构建,但它使用__cdecl进行64位构建.是的,Microsoft文档在这里有点弱!

检查.lib或.dll以查看其构建方式的最佳方法是使用dumpbin程序.这是一个例子:

dumpbin /headers libboost_thread-vc100-mt-gd-1_45.lib | findstr machine

您必须调整库名称以适应您当前链接的内容.这将明确地向您显示.lib或.dll是针对x86(32位)还是x64(64位).

翻译自:https://stackoverflow.com/questions/3164268/boostthread-build-error-unable-to-link-lib-unresolved-external


以上所述就是小编给大家介绍的《c – boost :: thread build error(无法链接lib \u0026\u0026未解析的外部)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Agile Web Application Development with Yii 1.1 and PHP5

Agile Web Application Development with Yii 1.1 and PHP5

Jeffrey Winesett / Packt Publishing / 2010-08-27

In order to understand the framework in the context of a real-world application, we need to build something that will more closely resemble the types of applications web developers actually have to bu......一起来看看 《Agile Web Application Development with Yii 1.1 and PHP5》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具