编译android版本htop

准备

编译环境:ubuntu 20.04.2
编译器版本:ndk-24.0.8215888
ncurses版本: 6.0
htop版本:3.2.2

1. 下载ncurses

    wget http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz
    tar -xvf ncurses-6.0.tar.gz

2. 配置环境 创建make_toolchain.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 make_toolchain.sh

创建 环境配置shell make_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 -I`pwd`/ncurses-6.0/install/include/ncurses -I`pwd`/ncurses-6.0/install/include"
    export LDFLAGS="-pie -L`pwd`/ncurses-6.0/install/lib"
    source make_env.sh

3. 编译ncurses

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

4. 编译htop

    git clone --recursive https://github.com/htop-dev/htop
    cd htop
    git checkout 3.2.2
    ./configure --host=aarch64-linux-android --prefix=`pwd`/install --disable-unicode
    make -j10

5. 拷贝到android并运行

    adb push htop /data/local/tmp/
    adb push libncurses*.so /data/local/tmp/
    export LD_LIBRARY_PATH=./
    ./htop

6. 报错及修改

错误一:
    LinuxProcessList.c:(.text+0x1400): undefined reference to `ffsl'
    
    修改方法,在文件开头定义, 修改linux/LinuxProcessList.c
    #define ffsl __builtin_ffsl
    
    
错误二:
    运行报错
    Error opening terminal: xterm-256color.
    
    找一台普通的linux主机
    将/usr/share/terminfo 拷贝到/data/local/tmp
    设置变量
    export TERMINFO=/data/local/tmp/terminfo
    export TERM=xterm-basic

7. 运行效果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

telllong

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

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

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

打赏作者

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

抵扣说明:

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

余额充值