[关闭]
@zwh8800 2017-08-23T02:17:57.000000Z 字数 1138 阅读 192324

为 openwrt 编译 htop

blog 归档 openwrt


为 openwrt 编译 htop


其实就和原来给电视棒交叉编译一样, 不过这次交叉编译器可让我好找…

路由器用的是华为的 hg255d, mips 的芯片, 16M flash, 64M sdram.

一般嵌入式开发都把内核和 app 分开的… 这个 openwrt 却不单独提供 toolchain. 只给一个内核源码包 (也不只是内核, 是内核和软件包的混合体…)

不过最后还是找到一个单独的工具链:

下载地址:

有了工具链一切就好办了. htop 依赖与 ncurses 所以先下载 ncurses.

  1. mkdir openwrt
  2. cd openwrt
  3. wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz
  4. wget http://downloads.sourceforge.net/project/htop/htop/1.0.2/htop-1.0.2.tar.gz

下载好之后, 在当前目录建一个文件夹 build, 编译后的文件就安装在这里, 然后分步解压

  1. mkdir build
  2. tar zxvf ncurses-5.9.tar.gz
  3. tar zxvf htop-1.0.2.tar.gz

然后先编译 ncurses:

  1. cd ncurses-5.9
  2. ./configure --prefix=/home/zzz/openwrt/build --host=mipsel-openwrt-linux --without-cxx --without-cxx-binding --without-ada --without-manpages --without-progs --without-tests
  3. make
  4. make install

后面几个 without 是去除 c++ 和 ada 支持以及不编译 manpage 和测试程序
然后就能发现在 build/lib 里有编译好的 ncurses 库了

之后编译 htop:

  1. cd htop-1.0.2
  2. ./configure --prefix=/home/zzz/openwrt/build --disable-unicode --host=mipsel-openwrt-linux LDFLAGS=-L/home/zzz/openwrt/build/lib
  3. make
  4. make install

LDFLAGS=-L/home/zzz/openwrt/build/lib 选项是为了加上链接库的路径

短暂等待过后, 在 build/bin 里应该能看见 htop.

拿到 openwrt 上运行又发生点问题. 提示
Error opening terminal: xterm.
上网 Google 一下发现需要设置 TERMINFO 环境变量:

  1. export TERMINFO=/usr/share/terminfo

[EOF]

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注