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