Compile Software for the Humax

From hummy.tv Wiki
Revision as of 14:14, 21 July 2015 by MymsMan (talk | contribs) (Added Cross compilation information)
Jump to: navigation, search

Compiling on-box

It is possible to compile some software directly on the Humax itself, however due to the limited amount of CPU horsepower available, this is only recommended for fairly small packages.

First you need to install the gcc and gawk packages. gcc is the compiler itself and automatically pulls in dependant packages, gawk is needed to properly support packages which use GNU autoconf, which most do.

humax# opkg install gcc gawk gmake

After this, close your telnet session and create a new one to properly set up the environment, and you are ready to compile your first piece of software on the Humax.

Warning: Problems with floating point

Whilst programs that use floating point number functions such as rint() may compile OK on the Humax box they may not produce the correct results on execution.

This appears to be because the on box compilers are configured to use software floating point libraries rather than hardware floating point. You can use compiler option -mhard-float to overcome the problem but this does generate warning messages from the compiler.

Until this problem is resolved it is best to use the cross compiler (see below) for code that requires floating point numbers.

Example - compiling the GNU zip (gzip) program

humax# cd /mod/tmp
humax# wget http://ftp.gnu.org/gnu/gzip/gzip-1.4.tar.gz
--2011-08-18 16:39:58--  http://ftp.gnu.org/gnu/gzip/gzip-1.4.tar.gz
Resolving ftp.gnu.org... 140.186.70.20
Connecting to ftp.gnu.org|140.186.70.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 907411 (886K) [application/x-gzip]
Saving to: `gzip-1.4.tar.gz'

100%[======================================>] 907,411      225K/s   in 4.2s    

2011-08-18 16:40:03 (210 KB/s) - `gzip-1.4.tar.gz' saved [907411/907411]

humax# tar -xvf gzip-1.4.tar.gz 
gzip-1.4/
gzip-1.4/zgrep.1
gzip-1.4/configure.ac
...

humax# cd gzip-1.4
humax# CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" \
    ./configure --prefix=/mod --build=mipsel-linux
checking for a BSD-compatible install... /mod/bin/busybox/install -c
checking whether build environment is sane... yes
...

humax# make
Making all in lib
make[1]: Entering directory `/mnt/hd2/mod/tmp/gzip-1.4/lib'
  GEN      alloca.h
  GEN      arg-nonnull.h
...

humax# ./gzip -V
gzip 1.4
Copyright (C) 2007 Free Software Foundation, Inc.

Cross compiling on an external host

To cross compile code to run on the Humax you need another Linux system on which to run the compiler, if you don't have another spare linux box laying around you can run it on a standard Windows system using Virtual Box. Oracle provide a number of pre-configured Linux systems which can be downloaded to prevent the need for a full linux install. You may need to update BIOS settings to enable the virtual machine to run (on HP System Configuration -> Device Configurations Enable Virtualization technology VT-x)

The actual cross compile is available from the HUMAX open source download site with the specific needed being entitled crosstools_hf-linux-2.6.18.0_gcc-4.2-11ts_uclibc-nptl-0.9.29-20070423_20090508.tar.bz2

Before downloading you are required to create an account - very simple process

Once downloaded to your linux system the file needs to be extracted under /opt/toolchains/ and set up your path appropriately.

Hint: due to the excessively long path and file names use symlinks to create shortcuts.

To reduce the hassle of building software libraries such as libsndfile copy the relevant headers and libraries across from the Humax box.

If running on a 64bit linux system you may experience error messages when compiling such as "bad ELF interpreter: No such file or directory" due to missing 32bit libraries, see here for how to fix.