在 MSVS 2013 中使用 libtorrent

Using libtorrent with MSVS 2013

我在 MSVS 2013 中使用 NuGet 包管理器安装了 libtorrent(版本 1.0.2)。当我 运行 这个看看我是否可以使用它时:

#include <libtorrent\session.hpp>

using libtorrent::session;

int main()
{
//  session ses;

    return 0;
}

我收到错误 error C1021: invalid preprocessor command 'warning'

这会将我带到 project_source\packages\libtorrent-src.1.0.2\lib\native\libtorrent\include\libtorrent\config.hpp 一行:

#warning unknown OS, assuming BSD

我不确定那是什么,我尝试按照 cplusplus.com 上的 post 将其更改为 #error,但出现了同样的错误。可能是愚蠢的,我评论了那条线,看看会发生什么,现在它把我带到 project_source\packages\libtorrent-src.1.0.2\lib\native\libtorrent\include\libtorrent\file.hpp

error C1083: Cannot open include file: 'unistd.h': No such file or directory

有什么解决办法吗?我试过不使用 NuGet,但无法从下载源中弄清楚如何使用 libtorrent。该网站对我帮助不大。

查看 config.hpp,假设 WIN32 宏是在 windows 上定义的。在你的情况下,情况似乎并非如此。

也许您可以尝试将其改为测试 _WIN32