HIP:TS-7000:cross-compiling

From Earlham CS Department
Jump to navigation Jump to search

about

This page describes the creation and usage of a toolchain for cross-compiling from a native linux environment to an ARM environment.

Building rdate to run in Technologic System's TS-Linux for ARM is used as an example, but the steps should be applicable to any application.

download, setup, and prepare the toolchain

You can download the cross-compilation toolchain from:

http://www.embeddedarm.com/software/software-arm-linux.php

The various toolchains are near the bottom of the page. Make sure to download the toolchain with the glibc that matches the glibc of whatever environment you want to compile to.

You can find out what verison of glibc is on your computer by running either:

"rpm -q glibc" for Redhat RPM based systems, or:

"ls -al /lib/libc*" for other systems.

Then use tar to unpack the toolchain. Depending on the type of file, you may need to use different commands to unpack it:

"tar -xvvf foo.tar"

"tar -xvzf foo.tar.gz"

"tar --use-compress-program bzip2 -xvf foo.tar.bz2"

The toolchain will come ready to use. Make sure you haven't unpacked it into your home directory, as the configure scripts expect files to be in a specific location, and if the tools are in locations above or below that due to being in a local directory, it will cause errors.

Next, set your path to the gcc that's included in the toolchain, this can be done in either your bash profile or .bashrc.

cross-compilation and migration

Download the code for the program that you want to compile, cd into the directory with the configure script, and run the script with the following command:

"./configure --host=arm-linux --build=arm --enable-static"

Note that you may need to change the --host= parameter depending on what environment you're compiling to.

The final step is to use the "file foo" command to make sure that it's built for the environment you wish to run it on, then copying it over to the environment you want to run it on.

example: rdate

I built rdate on b1.cluster.earlham.edu

Download rdate from http://linux.softpedia.com/get/System/System-Administration/Openrdate-17664.shtml

Download the toolchain from http://www.embeddedarm.com/linux/ARM.htm

I used the "Linux Crosstool gcc-3.3.4-glibc-2.3.2 - old abi" toolchain. Next, I used scp to bring the two files over to the cluster.

Use the following command to unpack the toolchain:

"tar --use-compress-program bzip2 -xvf foo.tar.bz2"

Go into .bashrc and set the path to the following:

/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/bin:${PATH}

Use the following command to unpack rdate:

"tar -xvzf foo.tar.gz"

Change directory into the rdate folder, and run the following command:

"./configure --host=arm-linux --build=arm --enable-static"

Run make

Use scp to copy the binary over to the pmp.

Cross Compiling for ARM on Stewie

  • login as user hip
hip@stewie:~$ cd development

  • the tool chain is in the directory arm_cross_compile_tools
hip@stewie:~/development$ cd arm-build/
wget http://example.com/foo-1.2.3.tar
cp build-program build-foo-1.2.3
mkdir Foo.1.2.3
gedit build-foo
  • using gedit, enter the correct paths by referring to the comments
file="$dir/program.tar"         # tar file
mdir="$dir/program"             # making/building dir
prefix="$dir/Program"           # installation dir
  • save and exit gedit
./build-foo-1.2.3
  • if everything went ok, foo-1.2.3 will be installed in Foo.1.2.3