C++ 错误LNK2019:未解析的外部符号;公众:

C++ 错误LNK2019:未解析的外部符号;公众:,c++,visual-studio-2008,C++,Visual Studio 2008,我正在VS2008中使用libtorrent创建一个torrent应用程序。我尝试了链接中给出的示例 但它向我展示了这些错误……如何解决它们 Linking... main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::~torrent_info(void)" (??1torrent_info@libtorrent@@QAE@XZ) referenced

我正在VS2008中使用libtorrent创建一个torrent应用程序。我尝试了链接中给出的示例 但它向我展示了这些错误……如何解决它们

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
链接。。。
main.obj:错误LNK2019:未解析的外部符号“public:\u thiscall libtorrent::torrent\u info::~torrent\u info(void)”(??1正确_info@libtorrent@@QAE@XZ)在函数_main中引用
main.obj:错误LNK2019:未解析的外部符号“public:\u thiscall libtorrent::torrent\u info::torrent\u info(struct libtorrent::lazy\u entry const&”)(?0更正_info@libtorrent@@QAE@ABUlazy_entry@1@@Z)在函数\u main中引用

main.obj:错误LNK2019:未解析的外部符号“class std::basic_ostream>和&uuuu cdecl libtorrent::operator&&uu cdecl libtorrent::operator
public:
不是未解析的符号。它之所以存在,是因为链接器试图告诉您(大多数)未解析的符号是公共成员函数


看起来您包含了“libtorrent”的标题,但没有链接到“libtorrent”库。

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

您是否在“配置属性”-->“C/C++”-->“常规”->“其他包含目录”?

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

配置属性/链接器/输入->其他依赖项:
libtorrent rasterbar.lib


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

项目中不包含.lib。请确保将其链接到中; 配置属性->链接器->输入->其他依赖项

另一种替代方法是简单地将.lib复制到您的项目文件夹中,但不这样做,这必然会在以后产生问题

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

如果输入库是32位的,而你在构建64位时使用它们,这可能是我拥有它的原因之一包含在我的项目中,但它原来是一个插件,设计用于在我的单元测试中不创建的实例。

是的,我正在使用libtorrent&在链接器>常规>我添加的其他库目录中:C:\boost\boost\u 1\u 36\u 0\stage\lib;“C:\Users\photoshop3\Documents\visualstudio 2008\Projects\Lib2\libtorrent“我还必须做什么?@amrit_neo:您还必须在项目设置中添加正确的库文件。[项目属性|配置属性|链接器|输入|其他依赖项]抱歉,我是VS和这个libtorrent的新手。我应该添加哪一个。以前我创建了一个应用程序,其中嵌入了浏览器,我添加了comctl32.lib。添加这个程序仍然不能解决我的问题是的,我正在使用libtorrent&在链接器>常规>附加库目录中我添加了:C:\boost\boost\u 1\u 36\u 0\stage\lib;“C:\Users\photoshop3\Documents\Visual Studio 2008\Projects\Lib2\libtorrent”我还需要做什么?我已经添加了头文件,但是在哪里可以获得torrent库?您可以从rasterbar软件的下载部分下载所需的版本()。如何创建此libtorrent-rasterbar.lib我找不到任何README文件,其中未提供任何有关创建lib的信息。我尝试了本文中给出的技术,但仍然无法创建lib文件README包含的构建说明。(1)请参阅docs/manual.html(2)运行:./configure后跟makeI添加了libtorrent-rasterbar.lib,但其显示错误:LINK:fatal error LNK1104:无法打开文件“libtorrent-rasterbar.lib”,现在在哪里可以找到此文件:(浏览你的libtorrent文件夹,首先查看文件是否存在。如果不存在,你需要自己编译。不,文件丢失了…如何编译..请告诉我