libbittorrent

AS4.4 boost 1.34.1 libtorrent 0.12

编译Boost

Boost 1.34.1开始去除了BJam V1的相关文件,使用BJam V2做为编译工具。编译Boost就要首先编译BJam源代码,生成BJam,然后再使用bjam编译Boost。

# tar xvfz boost_1_34_1.tar.gz
# cd boost_1_34_1/tools/jam/src
# sh ./build.sh

即可得到boost_1_34_1/tools/jam/src/bin.linuxx86/bjam程序,将bjam拷贝到操作系统的PATH变量能搜索到的路径如/bin下即可。例如:

cp boost_1_34_1/tools/jam/src/bin.linuxx86/bjam  /bin

下面就可以编译Boost了

cd boost_1_34_1
bjam stage

之所以不安装的boost是因为编译libtorrent不需要,而且安装后很可能和系统原来的boost库引起混乱。(如果你确定要安装,请参考http://blog.csdn.net/goodboy1881/archive/2006/03/27/640004.aspx

完成编译后所有的库文件都保存在boost_1_34_1/stage目录下,而头文件就在boost_1_34_1/boost/目录下。

编译libtorrent

输入下面的命令,告诉bjam哪里可以找到boost-build(boost-build是什么?我也说不清,反正这样做就能编译libtorrent -o-)

[writer@localhost boost_1_34_1]$ export BOOST_BUILD_PATH=boost_1_34_1/tools/build/v2

还要在boost_1_34_1/tools/build/v2/user-config.jam文件添加这么一行

using gcc ;

还要告诉bjam哪里可以找到boost库和头文件

[writer@localhost boost_1_34_1]$ export BOOST_ROOT=…../boost_1_34_1

把下载回来libtorrent-0.12.tar.gz放到目录并解压,进入它的目录并编译

[writer@localhost boost_1_34_1]$ cd ~
[writer@localhost boost_1_34_1]$ tar zxvf libtorrent-0.12.tar.gz
[writer@localhost boost_1_34_1]$ cd libtorrent-0.12/
[writer@localhost libtorrent-0.12]$ bjam

默认是编译成debug版的动态库的,可以加上release参数编译成release,或者加上link=static编译成静态库!

[writer@localhost libtorrent-0.12]$ bjam link=static release

libtorrent的源代码目录下面还有example和test目录,要编译他们进入他们的目录调用bjam即可!

[writer@localhost ~]$ cd libtorrent-0.12/example/
[writer@localhost ~]$ bjam
[writer@localhost ~]$ cd libtorrent-0.12/test/
[writer@localhost ~]$ bjam

编译出来的.o和可执行文件都保存在相应的bin目录下面相应的目录下,比如
libtorrent-0.12/bin/gcc/debug/dht-support-on/link-static/logging-none/threading-multi
libtorrent-0.12/bin/gcc/release/dht-support-on/link-static/logging-none/threading-multi
libtorrent-0.12/examples/bin/gcc/debug/dht-support-on/link-static/logging-none/threading-multi
libtorrent-0.12/examples/bin/gcc/release/dht-support-on/link-static/logging-none/threading-multi

还等什么,赶快到example目录下运行client_test体验下你的成果吧!

参考:http://www.liufei.com/blog/read.php/28.htm

page_revision: 2, last_edited: 1209889432|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License