找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 4517|回复: 0

libtorrent windows下VS2008编译及使用

[复制链接]
发表于 2012-3-9 21:34:08 | 显示全部楼层 |阅读模式
1.下载BOOST库,我下载的是1.39.0的版本
2. 编译boost库:运行boost根目录下bootstram.bat,得到bjam.exe
  
3. 使用bjam编译boost:bjam --without-python --toolset=msvc-9.0 --build-type=complete
   得到的链接库文件在stage/lib下,头文件在boost目录下
4. 下载libtorrent库,别下错,有两个版本,不同团队维护,我下载的是SourceForge上的0.14.5版本
5. 拷贝刚才boost根目录下的bjam文件到libtorrent根目录下
6. 新建批处理文件ltbuild.bat,内容如下:
    SET BOOST_BUILD_PATH=../boost_1_39_0/tools/build/v2
SET BOOST_ROOT=../boost_1_39_0
bjam --toolset=msvc-9.0 openssl=off link=static runtime-link=shared boost=source
   其中BOOST_BUILD_PATH和SET BOOST_ROOT根据自己的boost库的目录而定,bjam的参数可以查看libtorrent下docs目录下的building.html说明文件,我上面的参数分别表示:使用MSVC-9.0编译,不使用openssl,编译成静态库,C运行库采用动态链接方式,boost使用指定目录的boost,这样得到的静态库默认是debug版本,若需要编译release版本,可以查看building.html中的说明,指定一些宏。
7. 运行ltbuild.bat,可以在bin目录下得到libtorrent.lib

8.使用该库时需要注意,调用该库的工程需要定义一些宏,对于debug版本,需要定义TORRENT_DEBUG等预编译宏,与编译libtorrent时一致,具体可查看building.html的说明。
9. 新建一个工程,包含libtorrent的头文件,boost的头文件,引用boost下的stage/lib的boost库,以及libtorrent库,按照libtorrent提供的例子照写一个就可以测试了。
10. 如果需要使用openssl,需要自己编译OpenSSL,然后拷贝到VC头文件和库文件目录
copy
openssl-0.9.8\inc32\openssl
to
D:\Program Files\Microsoft Visual Studio 9.0\VC\include\openssl
copy
libeay32.lib
ssleay32.lib
to
D:\Program Files\Microsoft=20 Visual Studio 9.0\VC\lib
编译libtorrent时将openssl=on即可

您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-5-5 02:15 , Processed in 0.012588 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表