当前位置: 首页 > 工具软件 > LibTorrent > 使用案例 >

libtorrent java_libtorrent 编译

文彭祖
2023-12-01

一、OpenSSL的源码和编译环境下载:

OpenSSL安装过程

1. 安装ActivePerl程序,确保其bin目录在环境变量path里面

2. 解压OpenSSL源代码到 F:\openssl (目录自己定义)

3. 运行 Visual Studio 2008命令提示

4. 在命令行下输入如下命令:

F:

cd

openssl

perl

configure VC-WIN32

ms\do_ms

nmake -f

ms\ntdll.mak (编译静态版本的执行 nmake -f ms\nt.mak )

5. 编译完成后会在 F:\openssl\out32dll

目录下生成库文件、动态链接库文件、Openssl执行文件和测试程序,有用的文档就是三个 openssl.exe

libeay32.dll ssleay32.dll

注意:如果出现警告作为错误的error,请修改ms目录下的ntdll.mak文件,把-w3修改为-w0

二、编译boost

源文件准备

1、boost_1_39_0.tar.bz2,解压到F:\boost_1_39_0

2、http://icu-project.org/download/4.2.html下载icu4c-4_2_1-Win32-msvc9.zip,解压到F:\boost_1_39_0,出现F:\boost_1_39_0\icu,添加icu的bin目录到path环境变量中

编译

3、执行F:\boost_1_39_0\tools\jam\build_dist.bat,生成文件F:\boost_1_39_0\tools\jam\stage\bin.ntx86\bjam.exe,把bjam.exe拷贝到F:\boost_1_39_0目录下

4、在F:\boost_1_39_0目录新建一个bat文件,命名为:bootstrap_vc8.bat,内容为:

REM used with regex library with unicode support

set ICU_PATH="F:/boost_1_39_0/icu"

REM lib版本

bjam --without-python

--toolset=msvc-9.0

5、执行bootstrap_vc8.bat即可,结果生成的静态库放在F:\boost_1_39_0\stage\lib,动态库及编译文件都在F:\boost_1_39_0\bin.v2\libs中

三、编译libtorrent

源文件准备

1、从http://sourceforge.net/projects/libtorrent/下载libtorrent-rasterbar-0.14.4.tar.gz,解压到F:\libtorrent

2、下载openssl-1.0.0-beta3解压到F:\libtorrent\openssl-1.0.0-beta3

3、下载boost_1_39_0.tar.bz2解压到F:\boost_1_39_0

编译

3、按照我“使用Visual Studio 2008编译openssl”的文章编译opensll

4、按照我“使用Visual Studio 2008编译boost”的文章编译boost

5、新建win32 lib项目工程libtorrent

添加F:\libtorrent\src、F:\libtorrent\zlib和F:\libtorrent\src\kademlia下的所有源文件到工程

预编译宏添加

WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;

__USE_W32_SOCKETS;TORRENT_LOGGING;TORRENT_VERBOSE_LOGGING;

TORRENT_STORAGE_DEBUG;TORRENT_UPNP_LOGGING;TORRENT_DISK_STATS;

TORRENT_STATS;TORRENT_DHT_VERBOSE_LOGGING;TORRENT_VERBOSE_BANDWIDTH_LIMIT;

TORRENT_USE_OPENSSL;UNICODE;_UNICODE;CMAKE_INTDIR=\"Debug\"

头文件包含添加

f:\boost_1_39_0;F:\libtorrent\include;F:\libtorrent\zlib;"F:\libtorrent\openssl-1.0.0-beta3\include"

6、build即可

说明:如果要编译dll项目,除了添加如上预编译宏外,还要添加TORRENT_BUILDING_SHARED宏,然后添加引用的lib:

libeay32.lib

ssleay32.lib

libboost_date_time-vc90-mt.lib

libboost_filesystem-vc90-mt.lib

libboost_system-vc90-mt.lib

libboost_thread-vc90-mt.lib

添加lib引用路径:

F:\boost_1_39_0\stage\lib;F:\libtorrent\openssl-1.0.0-beta3\out32dll

完毕---本介绍是一次编译完libtorrent(包含zlib),没有独立编译zlib

下面是两个使用libtorrent的开源项目例子:

Linux:ctorrent

windows:halite

 类似资料: