调用libtorrent库报错,LNK2005已经在 asio.obj 中定义

1>------ 已启动生成:  项目: torrent_server, 配置: Debug x64 ------
1>  main.cpp
1>E:\torrent_server\libtorrent\include\libtorrent/alert.hpp(155): warning C4800: “const uint32_t”: 将值强制为布尔值“true”或“false”(性能警告)
1>E:\torrent_server\libtorrent\include\libtorrent/lazy_entry.hpp(216): warning C4244: “=”: 从“__int64”转换到“uint32_t”,可能丢失数据
1>E:\torrent_server\libtorrent\include\libtorrent/policy.hpp(365): warning C4267: “return”: 从“size_t”转换到“int”,可能丢失数据
1>E:\torrent_server\libtorrent\include\libtorrent/hasher.hpp(114): warning C4267: “参数”: 从“size_t”转换到“int”,可能丢失数据
1>E:\torrent_server\libtorrent\include\libtorrent/bitfield.hpp(54): warning C4267: “参数”: 从“size_t”转换到“int”,可能丢失数据
1>E:\torrent_server\libtorrent\include\libtorrent/bitfield.hpp(121): warning C4267: “参数”: 从“size_t”转换到“int”,可能丢失数据
1>  asio.cpp
1>  正在生成代码...
1>libtorrent.lib(asio.obj) : error LNK2005: "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category@error@asio@boost@@YAAEBVerror_category@system@3@XZ) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create@detail@asio@boost@@YAKXZ) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "void * __cdecl boost::asio::asio_handler_allocate(unsigned __int64,...)" (?asio_handler_allocate@asio@boost@@YAPEAX_KZZ) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "void __cdecl boost::asio::asio_handler_deallocate(void *,unsigned __int64,...)" (?asio_handler_deallocate@asio@boost@@YAXPEAX_KZZ) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup@winsock_init_base@detail@asio@boost@@KAXAEAUdata@1234@EE@Z) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::manual_startup(struct boost::asio::detail::winsock_init_base::data &)" (?manual_startup@winsock_init_base@detail@asio@boost@@KAXAEAUdata@1234@@Z) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::cleanup(struct boost::asio::detail::winsock_init_base::data &)" (?cleanup@winsock_init_base@detail@asio@boost@@KAXAEAUdata@1234@@Z) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::manual_cleanup(struct boost::asio::detail::winsock_init_base::data &)" (?manual_cleanup@winsock_init_base@detail@asio@boost@@KAXAEAUdata@1234@@Z) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::throw_on_error(struct boost::asio::detail::winsock_init_base::data &)" (?throw_on_error@winsock_init_base@detail@asio@boost@@KAXAEAUdata@1234@@Z) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "public: __cdecl boost::asio::io_service::io_service(void)" (??0io_service@asio@boost@@QEAA@XZ) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "public: __cdecl boost::asio::io_service::io_service(unsigned __int64)" (??0io_service@asio@boost@@QEAA@_K@Z) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "public: __cdecl boost::asio::io_service::~io_service(void)" (??1io_service@asio@boost@@QEAA@XZ) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "public: unsigned __int64 __cdecl boost::asio::io_service::run(void)" (?run@io_service@asio@boost@@QEAA_KXZ) 已经在 asio.obj 中定义
1>libtorrent.lib(asio.obj) : error LNK2005: "public: unsigned __int64 __cdecl boost::asio::io_service::run(class boost::system::error_code &)" (?run@io_service@asio@boost@@QEAA_KAEAVerror_code@system@3@@Z) 已经在 asio.obj 中定义

...

...

...
========== 生成:  成功 0 个,失败 1 个,最新 1 个,跳过 0 个 ==========
解决办法:

原因:

预处理器定义和libtorrent库定义的预处理器不一致

将主程序修改为一致:

WIN32
_DEBUG
_CONSOLE
_WIN32_WINNT=0x0501
WIN32_LEAN_AND_MEAN
_CRT_SECURE_NO_WARNINGS
BOOST_ASIO_ENABLE_CANCELIO
BOOST_ASIO_DYN_LINK
TORRENT_USE_OPENSSL

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值