[libtorrent] linux 搭建 libtorrent 开发编译环境

操作系统:ubuntu 20.04
(参考文档:http://libtorrent.org/building.html)
 

搭建 libtorrent 步骤:

一. 下载源码

    1. 从官网下载 libtorrent 源码
        git clone --recurse-submodules https://github.com/arvidn/libtorrent.git

    2. 安装 gcc
        sudo apt install gcc g++ automake autoconf git
 

二. 安装 boost 和搭建 BB2V

    1. 官网下载 boost
        https://www.boost.org/users/download/#live
        (本人下载的是 boost_1_75_0.tar.bz2 版本)

    2. 执行 bootstrap.sh
        cd boost_1_75_0
        ./bootstrap.sh --with-libraries=all --with-toolset=gcc
        如下图所示:
        

    3. 设置 BOOST_BUILD_PATH 环境变量
        gedit ~/.bashrc
        结尾添加:
        export BOOST_BUILD_PATH="$PATH:/home/dangwei/work/libtorrent/boost_1_75_0/tools/build"
        重启系统

    4. 新建 user-config.jam
        gedit ~/user-config.jam
        添加:
        using gcc ;
        (*注意,空格不能少)
        如下图所示:
        

    5. 新建 boost-build.jam
        cd boost_1_75_0
        gedit ./boost-build.jam
        添加:
        boost-build /home/dangwei/work/libtorrent/boost_1_75_0/tools/build/src ;
        (*注意,空格不能少)
        如下图所示:
        

    6. 编译 boost
        cd boost_1_75_0
        /b2 install --prefix=/usr/local
 

三. 安装 openssl

    1. 官网下载 openssl
         http://www.openssl.org/source/

    2. 解压
        tar -zxv openssl-1.1.1i.tar.gz

    3. 编译和安装
        cd openssl-1.1.1i/
        ./config --prefix=/usr/local/openssl
        sudo make install
 

四. 编译 libtorrent

    1. 编译 libtorrent
        cd libtorrent
        b2 install --prefix=/usr/local
        如下图所示:
        

    2. 编译 client-test
        cd examples
        b2 install --prefix=/usr/local
        如下图所示:
        

    3. 运行 client_test
        ./client_test
        路径如下图所示:
        
        

    4. 运行效果
        
        
        

 

大功告成。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值