deepin系统下编译使用libtorrent
安装openssl
查看系统是否安装ssl
openssl version -a
安装openssl
sudo apt install openssl
sudo apt install libssl-dev
安装boost
下载源码:https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.tar.gz
#解压
tar zxvf boost_1_64_0.tar.gz
cd boost_1_64_0
#设置安装路径
./bootstrap.sh --prefix=/usr/local/boost-1.64.0
#执行安装
sudo ./b2 install
#库目录写入环境变量
sudo echo "/usr/local/boost-1.64.0/lib/" >> etc/ld.so.conf
#环境变量更改永久生效
sudo ldconfig
安装ninja
先安装re2c
下载路径http://re2c.org/index.html
tar -xvzf re2c-1.0.3.tar.gz
cd re2c-1.0.3/
autoreconf -i -W all(没有configure可以先执行Autotools)
./configure
make
make install
源码编译ninja
git clone git://github.com/ninja-build/ninja.git && cd ninja
./configure.py --bootstrap
cp ninja /usr/bin/
编译libtorrent
下载最新libtorrent
https://codeload.github.com/arvidn/libtorrent/zip/RC_2_0
修改源码目录下的CMakelist.txt,增加boost库安装目录
set(BOOST_ROOT /home/uos/boost)
源码目录下的deps目录的try_signal文件夹为空,需要在作者仓库下去下载相应的源文件,否则编译不过。下载路径https://github.com/arvidn/try_signal
最后是libtorrent编译过程,参见http://libtorrent.org/building.html中building with cmake部分
Create a build directory for out-of-source build inside the libtorrent root directory:
mkdir build
and cd
there:
cd build
Run cmake
in the build directory, like this:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=14 -Dbuild_tests=ON -Dbuild_examples=ON -G Ninja ..
编译成功后可以在build目录下看到相应的库文件和测试程序
测试client_test
直接运行./client_test,如果提示找不到共享库文件,可以通过软连接方式在/usr/lib下生成共享库文件镜像
ln -s XXX源文件 XXX目的文件 !