我在我的项目中使用boost。我已经从这里下载了预编译的二进制文件http://boost.teeks99.com/

链接时,我收到这样的错误:
Error 18 error LNK2005: "public: void __cdecl boost::thread::join(void)" (?join@thread@boost@@QEAAXXZ) already defined in boost_thread-vc110-mt-1_52.lib(boost_thread-vc110-mt-1_52.dll) C:\Oleg\projects\MBClient\FastNativeAdapter\libboost_thread-vc110-mt-1_52.lib(thread.obj) FastNativeAdapter
为什么boost包含两个名字如此相似的lib,它们之间有什么区别?

  • libboost_thread-vc110-mt-1_52.lib
  • boost_thread-vc110-mt-1_52.lib

  • 如何修复链接错误?

    更新了我编译了自己。我已将boost_1_53_0\stage\lib目录添加到链接器。该目录实际上包含“每个”文件的3个“拷贝”,例如:
  • boost_atomic-vc110-mt-1_53.dll
  • boost_atomic-vc110-mt-1_53.lib
  • libboost_atomic-vc110-mt-1_53.lib

  • 因此,很明显编译器声称什么。由于某种原因,它无法理解要使用哪个版本的lib文件。它可能与静态/动态链接有关,但我仍然找不到解决方案。我确信我的问题很普遍,所以我希望有人可以建议我该怎么做。

    我尝试从文件夹中删除所有“libboost *”文件,但随后收到以下错误消息:Error 15 error LNK1104: cannot open file 'libboost_date_time-vc110-mt-1_53.lib'
    我尝试从文件夹中删除所有“boost * lib”文件,但随后收到以下错误消息:Error 15 error LNK1104: cannot open file 'boost_thread-vc110-mt-1_53.lib'
    然后我将boost_thread-vc110-mt-1_53.lib复制回去,并且收到很多类似的错误:
    Error 16 error LNK2005: "public: virtual __cdecl boost::detail::thread_data_base::~thread_data_base(void)" (??1thread_data_base@detail@boost@@UEAA@XZ) already defined in boost_thread-vc110-mt-1_53.lib(boost_thread-vc110-mt-1_53.dll)
    因此,当没有boost_thread-vc110-mt-1_53.lib编译器声称缺少它时,当没有boost_thread-vc110-mt-1_53.lib编译器声称“功能已经定义”时。大概我以某种方式确实同时使用了动态链接和静态链接?

    upd2 我没有将#define BOOST_ALL_DYN_LINK注释为建议的here,现在可以编译代码了!我正在调查是否其他一切都很好。但是我不明白为什么我应该取消注释#define BOOST_ALL_DYN_LINK,因此欢迎发表评论。

    最佳答案

    编辑:由于对帖子的更改更改了情况,因此删除了初始语句。

    基于http://www.boost.org/doc/libs/1_53_0/more/getting_started/unix-variants.html#library-naming(由Igor R.提供):

    libboost_thread-vc110-mt-1_52.lib是静态lib(不需要DLL)
    boost_thread-vc110-mt-1_52.lib是DLL的导入库

    您只需要使用其中之一即可。

    关于c++ - 链接错误: ambiguous libboost*. lib vs boost * .lib,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16056461/

    10-12 00:13
    查看更多