Cross compiling htop

· udik's blog


Assume toolchain path is /home/user/myd-y6ulx-m44/03-Tools/Toolchain/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/

  1. Bring toolchain to $PATH:
1$ export PATH=$PATH:/home/user/myd-y6ulx-m44/03-Tools/Toolchain/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/
  1. Clone htop and ncurses source code:
1$ cd /tmp/
2$ git clone https://github.com/htop-dev/htop
3$ git clone https://github.com/gittup/ncurses
  1. Cross-compile ncurses:
1$ cd ncurses/
2$ ./configure --target=arm-linux-gnueabihf --with-gcc=arm-linux-gnueabihf-gcc --with-shared --host=arm-linux-gnueabihf --with-build-cpp=arm-linux-gnueabihf-g++ --disable-unicode
3$ make

After successfull build .so should appear in /tmp/ncurses/lib

  1. Cross-compile htop:
1$ cd /tmp/htop
2$ ./autogen.sh
3$ export CPPFLAGS=-I/tmp/ncurses/include
4$ export LDFLAGS=-L/tmp/ncurses/lib
5$ ./configure --target=arm-linux-gnueabihf --with-gcc=arm-linux-gnueabihf-gcc --with-shared --host=arm-linux-gnueabihf --with-build-cpp=arm-linux-gnueabihf-g++ --disable-unicode

After successfull build htop executable file should appear in /tmp/htop. Check that cross-compile done:

1$ file htop
2htop: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.16, BuildID[sha1]=f6fcb6836ce7831ff7841ad48ab68d8736bc98db, with debug_info, not stripped
  1. Deploy content of /tmp/ncurses/lib/ to /usr/lib on a target machine and copy the /tmp/htop/htop file on it.
  2. On a target machine:
1$ export TERMINFO=/etc/terminfo
  1. Done!

Working htop on IMX6