htop静态交叉编译

一、准备
1、交叉编译链:arm-ca9-linux-gnueabihf-6.5
2、工具安装
apt-get install automake
apt install libtool
3、源码下载
ncurses-5.9.tar.gz
htop-2.2.0.tar.gz
将源码放在工作目录,比如:/home/cxyazhou/work/
二、编译ncurses
1、解压源码且进入目录
2、新建编译脚本build.sh

#!/bin/sh
 
#Ncurses Compilation Error-error: expected ')' before 'int'
export CPPFLAGS="-P"

HOST=arm-ca9-linux-gnueabihf
DIR=$PWD/install
CC=/opt/nova-linux/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-gcc

if [ ! -d ${DIR} ]; then
    mkdir -p ${DIR}
fi

./configure CC=${CC} --prefix=${DIR}  --host=${HOST} --without-cxx --without-cxx-binding --without-ada --without-manpages --without-progs --without-tests --with-terminfo-dirs="/var/mkk/htop/terminfo:/lib/terminfo:/usr/share/terminfo"

if [ $? -eq 0 ]; then
    sed -i "s/extern NCURSES_EXPORT(bool)    mouse_trafo (int\*, int\*, bool);.*/extern NCURSES_EXPORT(bool)    mouse_trafo (int\*, int\*, bool);/"  include/curses.h
    make && make install 
fi

3、注意这个参数:–with-terminfo-dirs,后面程序运行需要在这里指定的目录下找terminfo文件,这里的配置决定后面把文件放在哪里。
4、运行build.sh,则会编译成功
5、aarch64-ca53-linux-gnu编译链报错解决:
下载新文件,然后替换旧文件即可
wget -O config.guess ‘http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD’
wget -O config.sub ‘http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD’
三、编译htop
1、解压源码且进入目录
2、拷贝ncurses的静态库到当前目录
cp …/ncurses-5.9/install/lib/libncurses.a .
3、修改configure

#删除
if test "x$ac_cv_lib_ncurses_refresh" = xyes; then :


$as_echo "#define HAVE_LIBNCURSES 1" >>confdefs.h

      LIBS="-lncurses $LIBS "

else
  missing_libraries="$missing_libraries libncurses"

fi

#增加
$as_echo "#define HAVE_LIBNCURSES 1" >>confdefs.h
LIBS="libncurses.a $LIBS "

4、新建编译脚本build.sh

#!/bin/sh

HOST=arm-ca9-linux-gnueabihf
DIR=$PWD/install
CC=/opt/nova-linux/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-gcc
AR=/opt/nova-linux/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-ar
RANLIB=/opt/nova-linux/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-ranlib
STRIP=/opt/nova-linux/arm-ca9-linux-gnueabihf-6.5/bin/arm-ca9-linux-gnueabihf-strip

if [ ! -d ${DIR} ]; then
    mkdir -p ${DIR}
else    
    rm -rf install/*
fi

./configure --host=${HOST} --prefix=${DIR} CC=${CC} AR=${AR} RANLIB=${RANLIB} --disable-unicode CPPFLAGS=-I/home/cxyazhou/work/ncurses-5.9/install/include

if [ $? -eq 0 ]; then
    make && make install 
    ${STRIP} install/bin/htop
fi

5、运行build.sh后,编译成功,生成htop。
四、程序打包
mkdir /home/cxyazhou/work/htop/
cp /home/cxyazhou/work/htop-2.2.0/htop /home/cxyazhou/work/htop/
cp /home/cxyazhou/work/ncurses-5.9/install/share/terminfo/ /home/cxyazhou/work/htop/ -rf
五、运行程序
1、在板子里创建目录
mkdir /var/mkk;
2、使用nfs或者tftp将htop包目录放在/var/mkk下
3、运行程序
cd /var/mkk/htop
./htop
4、注意terminfo下的文件并不是都需要,可以删除所有后运行程序,会提示缺少哪个文件,只要保留需要的即可。
5、securecrt无法直接保存htop的输出,原因?
6、将htop的输出写到文件
while true; do echo | ./htop >> /var/mkk/htop.txt;sleep 1; done
如果要查看文件内容的话,需要cat htop.txt,直接用记事本打开是乱码。
7、将htop输出转为html
while true; do echo q | ./htop | ./aha --black --line-fix > htop.html; cat htop.html; sleep 1; done

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序员阿周

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

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

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

打赏作者

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

抵扣说明:

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

余额充值