【问题标题】:error LNK2019: unresolved external symbol "public:错误 LNK2019:未解析的外部符号“公共:
【发布时间】:2011-01-25 06:55:27
【问题描述】:

我正在 VS 2008 中使用 libtorrent 创建一个 torrent 应用程序。我尝试了链接 http://www.rasterbar.com/products/libtorrent/examples.html 中给出的示例 但是它向我显示了这些错误....如何解决它们?

Linking...
main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::~torrent_info(void)" (??1torrent_info@libtorrent@@QAE@XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::torrent_info(struct libtorrent::lazy_entry const &)" (??0torrent_info@libtorrent@@QAE@ABUlazy_entry@1@@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "class std::basic_ostream > & __cdecl libtorrent::operator<<(class std::basic_ostream > &,struct libtorrent::lazy_entry const &)" (??6libtorrent@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABUlazy_entry@0@@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "int __cdecl libtorrent::lazy_bdecode(char const *,char const *,struct libtorrent::lazy_entry &,int)" (?lazy_bdecode@libtorrent@@YAHPBD0AAUlazy_entry@1@H@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: void __thiscall libtorrent::lazy_entry::clear(void)" (?clear@lazy_entry@libtorrent@@QAEXXZ) referenced in function "public: __thiscall libtorrent::lazy_entry::~lazy_entry(void)" (??1lazy_entry@libtorrent@@QAE@XZ)
main.obj : error LNK2019: unresolved external symbol "void __cdecl libtorrent::to_hex(char const *,int,char *)" (?to_hex@libtorrent@@YAXPBDHPAD@Z) referenced in function "class std::basic_ostream > & __cdecl libtorrent::operator<<(class std::basic_ostream > &,class libtorrent::big_number const &)" (??6libtorrent@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABVbig_number@0@@Z)
main.obj : error LNK2019: unresolved external symbol "public: struct libtorrent::peer_request __thiscall libtorrent::file_storage::map_file(int,__int64,int)const " (?map_file@file_storage@libtorrent@@QBE?AUpeer_request@2@H_JH@Z) referenced in function "public: struct libtorrent::peer_request __thiscall libtorrent::torrent_info::map_file(int,__int64,int)const " (?map_file@torrent_info@libtorrent@@QBE?AUpeer_request@2@H_JH@Z)
C:\Users\photoshop3\Documents\Visual Studio 2008\Projects\Lib2\Debug\Lib2.exe : fatal error LNK1120: 7 unresolved externals

【问题讨论】:

    标签: c++ visual-studio-2008


    【解决方案1】:

    .lib 不包含在您的项目中。确保你正在链接它; 配置属性 -> 链接器 -> 输入 -> 附加依赖项

    另一种选择是简单地将 .lib 复制到您的项目文件夹中,但不要这样做,这势必会在以后产生问题。

    有时 .lib 没有随库一起提供,因此您需要自己编译。 自述文件会告诉你这一点。如果是这种情况,他们通常会附带一个 .sln 文件,您可以打开它,然后将其编译成一个 .lib 文件,然后您可以在主应用程序中引用该文件,正如我在上面所写的那样

    【讨论】:

    • 我添加了 libtorrent-rasterbar.lib,但它显示错误: LINK : fatal error LNK1104: cannot open file 'libtorrent-rasterbar.lib' now 我在哪里可以找到这个:(
    • 首先浏览您的 libtorrent 文件夹并查看该文件是否存在。如果没有,则需要自己编译。
    • 没有文件丢失...如何编译它..请告诉我
    【解决方案2】:

    你是否在“配置属性”-->“C/C++”-->“常规”-->“附加包含目录”中添加了头文件的路径?

    【讨论】:

      【解决方案3】:

      link 只为您提供 libtorrent 的源代码(包括头文件)。您应该编译此源以获得 .lib 文件。将此 .lib 文件添加到您的客户端:

      配置属性/链接器/输入 -> 附加依赖:libtorrent-rasterbar.lib

      编译的最佳起点应该是 README 文件。

      【讨论】:

      • 如何创建这个 libtorrent-rasterbar.lib 我在任何地方都找不到它
      • 在 README 中没有给出关于 lib 创建的任何内容。我尝试了limewire.negatis.com/index.php?title=Visual_Studio_libtorrent 中给出的技术,但仍然无法创建 lib 文件
      • 自述文件包括构建指令。 (1) 见docs/manual.html (2) 运行:./configure 后跟make
      【解决方案4】:

      public: 不是未解析的符号。它之所以存在,是因为它试图告诉您(大多数)未解析符号是公共成员函数的链接器。

      您似乎已包含“libtorrent”的标头,但未链接到“libtorrent”库。

      【讨论】:

      • 是的,我在 LInker>General>Additional Library 目录中使用 libtorrent & 我添加了:C:\boost\boost_1_36_0\stage\lib; "C:\Users\photoshop3\Documents\Visual Studio 2008\Projects\Lib2\libtorrent" 我还要做什么?
      • @amrit_neo:您还必须在项目设置中添加正确的库文件。 [项目属性|配置属性 |链接器 |输入 |其他依赖项]
      • 抱歉,我是 VS 和这个 libtorrent 的新手。我应该添加哪一个。以前,我创建了一个嵌入了浏览器的应用程序,其中我添加了 comctl32.lib。添加这个仍然不能解决我的问题
      【解决方案5】:

      您可能没有链接到 torrent 库或指定了错误的路径,导致链接器无法找到它。

      【讨论】:

      • 是的,我在 LInker>General>Additional Library 目录中使用 libtorrent & 我添加了:C:\boost\boost_1_36_0\stage\lib; "C:\Users\photoshop3\Documents\Visual Studio 2008\Projects\Lib2\libtorrent" 我还要做什么?
      • 我已经添加了头文件,但是在哪里可以获取 torrent 库?
      • 您可以从rasterbar软件(rasterbar.com/products/libtorrent/index.html)的下载区下载您需要的版本。
      【解决方案6】:

      如果输入库是 32 位的,而您正在使用它们来构建 64 位,这可能是原因之一

      【讨论】:

        【解决方案7】:

        对我来说,我将它包含在我的项目中,但结果证明它是一个插件,旨在不在我的单元测试中创建实例。

        【讨论】:

          猜你喜欢
          • 2016-07-21
          • 1970-01-01
          • 2023-03-28
          • 2012-10-31
          • 2012-08-31
          相关资源
          最近更新 更多