1 交叉编译htop工具到基于mips芯片的openwrt系统
1.1 背景
在一些嵌入式系统上,很多工具都没有,像top,想看个内存使用,进程,cpu使用率,htop有源码,所以想着把htop交叉编译到这个嵌入式设备上。
1.2 下载htop源码
http://hisham.hm/htop/index.php?page=downloads
打开以下链接,git clone到本地即可。
git clone https://github.com/hishamhm/htop
1.3 git clone到本地之后、chmod 777 htop/* -R
1.4 进入htop目录,执行./autogen.sh
1.5 htop依赖的共享库目录
因为是openwrt平台,htop交叉编译所需要的库都在以下目录下,根据个人编译openwrt而定,所以在configure的时候,直接加上以下链接库的目录就可以了
htop依赖的共享库所在目录
/home/zze/hdl/openwrt/staging_dir/target-mipsel_24kc_musl/usr/lib
1.6 configure
下面指定libncurses库及头文件的路径,还有编译器
CFLAGS="-I/home/zze/hdl/openwrt/staging_dir/target-mipsel_24kc_musl/usr/include" LIBS="-L/home/zze/hdl/openwrt/staging_dir/target-mipsel_24kc_musl/usr/lib
-lncursesw -lncurses" ./configure --host=mipsel-openwrt-linux-musl CC=mipsel-openwrt-linux-musl-gcc --prefix=/home/zze/hdl/lib/htop
1.7 make && make install
编译的可执行程序在/home/zze/hdl/lib/htop目录 下
file查看,可知是一个动态链接库。
通过scp或者winscp工具,拷贝至openwrt平台下
把htop需要的动态库也一拷贝于/lib下
1.8 运行
完美完成任务
1.9 参考
https://www.cnblogs.com/txsf/p/3713991.html