Cross compiling
Published by packi on
Updated by packi on

Last week I’ve had to port some software I wrote to an ARM9 development board (I’ve been working on a part of digitalSTROM for the last year). I figured that this would be a mostly painless task and learned that it is — if you know which files to adjust. Thats why I’m documenting it for you all here.

The libraries I had to compile were:

  • Boost
  • LibXML
  • LibICAL
  • gsoap++
  • libjs (yeah JS on a small ARM9 board, ain’t that cool?)

Boost

Well boost was a bitch to compile. Until I found a post in a mailinglist from someone who did something similar. I might have been easier with 1.37 but I’m stuck at 1.35 for now.

export PATH=/opt/emlix/picocom1/bin:$PATH
echo "using gcc : arm : arm-linux-gnueabi-g++ ;" > user-config.jam
BOOST_BUILD_PATH=. tools/jam/src/bin.linuxx86/bjam -d2 
--toolset=gcc-arm '-sBUILD=release static multi/single' link=static 
--prefix=../sysroot/ --layout=system --with-filesystem 
--debug-configuration install

The --debug-configuration command line switch was a life-safer. I discovered it a little late though.

LibXML2

LibXML2 was straight forward:

export PATH=/opt/emlix/picocom1/bin:$PATH
export CC=arm-linux-gnueabi-gcc
./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi \
--build=i586-linux --prefix=/home/patrick/test/sysroot/ \
--with-minimum --with-writer --with-sax1
make
make install

The only hassle was to find out that i had to include sax1 and writer for my program.

LibICAL

Straight forward as well:

export PATH=/opt/emlix/picocom1/bin:$PATH
export CC=arm-linux-gnueabi-gcc
./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi \
--build=i586-linux --prefix=/home/patrick/test/sysroot/ \
--without-bdb4
make
make install

gsoap

The problem with gsoap is that it needs to generate files to compile, but
it’s basically following the pattern:

export PATH=/opt/emlix/picocom1/bin:$PATH
export CC=arm-linux-gnueabi-gcc
export CXX=arm-linux-gnueabi-g++
./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi \
--build=i586-linux --prefix=/home/patrick/test/sysroot/
make

Then you’re greeted by this error message:

../../gsoap/src/soapcpp2: ../../gsoap/src/soapcpp2: cannot execute binary file

Which is obvious considering we’re compiling for ARM9. No you can either copy the files over to your board and execute them there or just call your native soapcpp2

cd wsdl
../soapcpp2 -SC -pwsdl -I../import ./wsdl.h

After that you’re compile-run should run smooth through until the end:

make
make install

SpiderMonkey (libjs)

Since SpiderMonkey is usually embedded in the Mozilla build-process it just has a simple Makefile. Either that or they’re just lazy at Mozilla. Here are the steps to compile that beast:

mkdir mozilla
cd mozilla
wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar xzf js-1.7.0.tar.gz
cd js
make -f Makefile.ref CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld

The build comes to a grinding halt since we’re having the “running ARM9 binaries on a x86 platform”-issue again. This time it might be a good advice to run these binaries your target-processor since it’s checking the size of various types. Copy over jscpucfg and run it like that:

./jscpucfg > jsautocfg.h

Continue the build:

make -f Makefile.ref CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld

Next stop: [...]jskwgen: cannot execute binary file. Again copy over jskwgen and run it on your target (it might work with your native copy if you’ve got one lying around, as far as I can tell it just generates parts of the parser):

./jskwgen > jsautokw.h

And continue the build:

make -f Makefile.ref CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld

Your binaries should be located in the Linux_All_DBG.OBJ sub-directory.

Comments
by anon@c114-77-19-30.brasd3.vic.optusnet.com.au -

Thanks for the info on cross compiling.

I had to compile libjs for MIPSEL and got stumpted when the makefile was trying to execute MIPSEL binaries on my X86 machine (Cygwin). So the tip of copying the MIPSEL binaries to the target machine was very helpful.

But, there were a couple of differences.
My makefile kept deleting jsautocfg.h, so I commened out the line with rm -f jsautoconf.h in it in Makefile.ref
(its a bit of a hack, but it works!)

Also in the makefile, jskwgen takes the output file as the first arguement. So I ran ./jskwgen jsautokw.h on the target system to generate jsautokw.h
But I can see now that if I omit the output file jskwgen just outputs to stdio, so you can redirect it to a file like you did.

Anyway. Great tips

Thanks again.

Roger Clark

by anon@NSG-Static-090.113.72.182.airtel.in -

I want to achieve something like this

I have 4 C source and header files and with using “arm-uclinuxeabi-gcc” I want to compile and create one single executable file..? and need to add this to my kernel Image.

In our host machine in order to generate binary file we used commands like this

“gcc -o calc calc.c stdsoap2.c soapC.c soapClient.c”


After this step we got “calc” binary file this works.

how to achieve this step in uclinux using arm-uclinux crass compiler to generate single executable binary file…??
actual intension to port gsoap to ulinux and run on target machine.

when I compiled its giving error like this
…………………………………………………………………….
……………………………………………………………..
Building modules, stage 2.
MODPOST 0 modules
make[1]: Leaving directory `/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/linux’
make -C app all CFLAGS=“-Os -mcpu=cortex-m3 -mthumb -I/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/A2F/root/usr/include” LDFLAGS=“-mcpu=cortex-m3 -mthumb -L/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/A2F/root/usr/lib”
make[1]: Entering directory `/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/projects/solus_test/app’
arm-uclinuxeabi-gcc -Os -mcpu=cortex-m3 -mthumb -I/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/A2F/root/usr/include -o calc calc.c soapC.c soapClient.c /home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/projects/solus_test/app/stdsoap2.c
Critical error: Cannot open file “arm-uclinuxeabi-gcc -Os -mcpu=cortex-m3 -mthumb -I/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/A2F/root/usr/include -o calc calc.c soapC.c soapClient.c /home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/projects/solus_test/app/stdsoap2.c “ for reading
make[1]: *** [calc] Error 1
make[1]: Leaving directory `/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/projects/solus_test/app’
make: *** [app] Error 2
root@amarayya-System-Product-Name:/home/amarayya/doc/LPC1788/linux-lpc-1.9.0/linux-cortexm-1.9.0/projects/solus_test#

how can I fix critical error in crass compiler and what is the reason for it..?