Pdaxrom: Cross Compilation
From OESF
The steps of this tutorial have been tested on an ubuntu-x86 box. If you don't have linux installed on a PC, you can use:
- the pdax86 live cd BROKEN LINK. You will need to mount a partition from your hard disk. More info on this asap.
- the vmware pdax86 image BROKEN LINK. Download and install the free vmware player open the file contained in the archive.
pdax86 is just like pdaxrom on your Zaurus, except that it runs on a desktop pc. The benefit of using this distribution rather than another one is that it contains all the libraries and utilities with which the cross-compiler has been built. Note the cross compiler will not work under cygwin, MacOsx or non x86 linux (ie linux-ppc). The cross compiler contains linux-x86 binaries.
Contents |
Installation
download the cross sdk
Go to the pdaxrom download page (link needs updating) and fetch the cross compiler archive you need, for instance for my SL-C860 I use cross-sdk-armv5tel-cacko-linux-3.4.5-2.2.5-softfloat.tar.bz2 (again, link is broken)
uncompress the archive in the root directory
On my ubuntu box, I need super user rights to do this, so I use sudo.
ubuntu@ubuntu:/$ cd / ubuntu@ubuntu:/$ sudo tar jxvf ~/Desktop/cross-sdk-armv5tel-cacko-linux-3.4.5-2.2.5-softfloat.tar.bz2
libiconv
If you use pdax86, you can skip this step. pdaxrom uses libiconv to avoid the dependency on gconv. However most recent linux distributions use the functions from the glibc library rather than a separate libiconv. If your system doesn't have libiconv.so.2 installed, for instance if you get the error:
error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
while running arm-cacko-linux-gcc, you need to install the library.
First download libiconv.so.2, place it in /opt/cross/arm/3.4.5-xscale-softvfp/lib/ and make it executable:
ubuntu@ubuntu:/$ sudo mv ~/Desktop/libiconv.so.2 /opt/cross/arm/3.4.5-xscale-softvfp/lib/libiconv.so.2 ubuntu@ubuntu:/$ sudo chmod a+x /opt/cross/arm/3.4.5-xscale-softvfp/lib/libiconv.so.2
Then modify /opt/cross/arm/3.4.5-xscale-softvfp/runsdk.sh add the line, somewhere with the other export, before bash:
export LD_LIBRARY_PATH=/opt/cross/arm/3.4.5-xscale-softvfp/lib
For instance use:
ubuntu@ubuntu:/$ sudo gedit /opt/cross/arm/3.4.5-xscale-softvfp/runsdk.sh
That's it, the cross-compiler is installed
Usage.
initialize the environment
The cross-compiler contains a little script that will set up the right environment variables: runsdk.sh. Use the sdk only in a terminal where you have previously run this script. The script does not set the environment of the whole system.
ubuntu@ubuntu:~$ /opt/cross/arm/3.4.5-xscale-softvfp/runsdk.sh Type exit for leave armv5tel-cacko-linux cross environment. ubuntu@ubuntu:~$
try the compiler
Make sure to be in a directory where you have enough rights (for instance go to your home directory)
ubuntu@ubuntu:~$ cd
ubuntu@ubuntu:~$ echo -e '#include "stdio.h"\n int main(){ printf("Hello World\\n"); }' > hello.c
ubuntu@ubuntu:~$ armv5tel-cacko-linux-gcc -o hello hello.c
ubuntu@ubuntu:~$ file hello
hello: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not stripped
ubuntu@ubuntu:~$
You can try now to run "hello" on you zaurus. Hopefully you have successfully cross-compiled your first programs for pdaxrom. :)
cross-compiling an application- an example compiling links2
download and uncompress the sources:
ubuntu@ubuntu:~$ wget http://links.twibright.com/download/links-2.1pre20.tar.gz ubuntu@ubuntu:~$ tar zxvf links-2.1pre20.tar.gz ubuntu@ubuntu:~/links-2.1pre20$ cd links-2.1pre20
configure:
- first check the README and other installation instructions
A lot of applications for linux can be compiled and installed with a simple "./configure;make; make install". But this is not always the case. Save your time, and do read the instructions!
- If your application provides a configure script have a look at the options :
ubuntu@ubuntu:~/links-2.1pre20$ ./configure --help
in most cases running "./configure --host=armv5tel-cacko-linux --build=i686-linux" is enough but here it fails:
configure: error: no acceptable cc found in $PATH
We need to specify the compiler using the CC environment variable, like this:
ubuntu@ubuntu:~/links-2.1pre20$ CC=armv5tel-cacko-linux-gcc ./configure --host=armv5tel-cacko-linux --build=i686-linux --enable-graphics --enable-javascript
I have also added 2 more options for graphics and javascript support This is enough to configure links2, but it's not always that easy. Other options and variables that you might need to set:
- --x-includes=/opt/cross/arm/3.4.5-xscale-softvfp/armv5tel-cacko-linux/include --x-libraries=/opt/cross/arm/3.4.5-xscale-softvfp/armv5tel-cacko-linux/lib
- CC=armv5tel-linux-gcc CXX=armv5tel-linux-g++
- LDFLAGS="-Wl,-rpath-link,/opt/cross/arm/3.4.5-xscale-softvfp/armv5tel-cacko-linux/lib
But even with these, configure might still fail. Cross-compilation is not always straightforward, you can try to get some help on the oesf.org forums
compilation
on ubuntu you might need to install the make package:
ubuntu@ubuntu:~$ sudo apt-get install make
We are now ready to launch the compilation:
ubuntu@ubuntu:~/links-2.1pre20$ make
Hopefully after some time the compilation should end successfully.
installation:
first we are going to create a directory where the application is to be installed:
ubuntu@ubuntu:~/links-2.1pre20$ mkdir ipkg-temp
next we specify the destination using the variable DESTDIR:
ubuntu@ubuntu:~/links-2.1pre20$ make DESTDIR=/home/ubuntu/links-2.1pre20/ipkg-temp/ install
Again, not all applications uses the DESTDIR variable, to check this I usually do:
ubuntu@ubuntu:~/links-2.1pre20$ grep DESTDIR Makefile
DESTDIR =
$(mkinstalldirs) $(DESTDIR)$(bindir)
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/
If it returns something, then there is a good chance that DESTDIR is valid.
Now you have an install tree that you can put and try on your Zaurus in ipkg-tmp/
a bit more on installation
You can strip the binary files it will reduce their size, here:
ubuntu@ubuntu:~/links-2.1pre20$ cd ipkg-temp/usr/local/bin/ ubuntu@ubuntu:~/links-2.1pre20/ipkg-temp/usr/local/bin$ ls -l links -rw------- 1 ubuntu ubuntu 4720295 2005-12-28 16:33 links ubuntu@ubuntu:~/links-2.1pre20/ipkg-temp/usr/local/bin$ armv5tel-cacko-linux-strip links ubuntu@ubuntu:~/links-2.1pre20/ipkg-temp/usr/local/bin$ ls -l links -rw------- 1 ubuntu ubuntu 3018352 2005-12-29 03:45 links ubuntu@ubuntu:~/links-2.1pre20/ipkg-temp/usr/local/bin$
Sometimes the Makefile provides an install-strip target, that will strip the binaries for you. here:
ubuntu@ubuntu:~/links-2.1pre20$ make DESTDIR=/home/ubuntu/links-2.1pre20/ipkg-temp/ install-strip
install-strip fails because it tries to use "strip" instead of "armv5tel-cacko-linux-strip". Passing an environment variable STRIP during the configuration might solve this problem.
making an ipk
This is discussed in another howto.

