编译android版本binutils工具

编译android版本binutils工具

准备

编译环境:ubuntu 20.04.2
编译器版本:ndk-24.0.8215888
binutils版本: 2.33.1

1. 生成android standline toolchain工具包shell_tool.sh

    # Create an arm64 API 26 libc++ toolchain.
    $ANDROID_NDK/build/tools/make_standalone_toolchain.py \
      --arch arm64 \
      --api 26 \
      --install-dir=`pwd`/aarch64-linux-android-toolchain

执行

sh shell_tool.sh

2. 配置编译工具的环境变量shell_env.sh 内容如下:

    # Add the standalone toolchain to the search path.
    export PATH=$PATH:`pwd`/aarch64-linux-android-toolchain/bin

    # Tell configure what tools to use.
    target_host=aarch64-linux-android
    export AR=$target_host-ar
    export AS=$target_host-clang
    export CC=$target_host-clang
    export CXX=$target_host-clang++
    export LD=$target_host-ld
    export STRIP=$target_host-strip

    # Tell configure what flags Android requires.
    export CFLAGS="-fPIE -fPIC -Wno-error -Wno-null-pointer-arithmetic"
    export LDFLAGS="-pie"

执行

    source shell_env.sh

3. 下载binutils源码

    wget https://mirror.csclub.uwaterloo.ca/gnu/binutils/binutils-2.33.1.tar.xz
    tar -xvf binutils-2.33.1.tar.xz

4. 编译binutils

    ./configure --host=aarch64-linux-android --prefix=`pwd`/install
    make -j10 && make

5. 拷贝到android执行ld试用

    adb push `pwd`/install /data/local/tmp/
    adb shell
    cd /data/local/tmp
    ./ld  clang++

测试结果

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

telllong

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值