Re: [SPAM?]: Re: cross-compiling
Hello,
ER wrote:
> The question, is How to use it? How can I use it to cross
> compile an application?
Short answer: not with dpkg-cross alone.
Long answer: to cross compile an application (for arm, say):
1. Build a toolchain.
See http://www.emdebian.org/tools/crossdev.html
After that you have cross-binutils (/usr/arm-linux/bin/ld ...), a cross-compiler
(arm-linux-gcc ...), and a set of libraries providing binary stuff for the target
platform (/usr/arm-linux/lib/... ), most notably a libc...so
Here dpkg-cross can simplify your life: you can download the BINARY lib..._arm.deb
packages on your (e.g. intel) host platform and then convert the package such
that it is installed in /usr/arm-linux/lib ... at your convenience. It saves you
from cross-compiling the libraries yourself, and it saves you from dissecting
the .deb package yourself. dpkg-cross does NOT cross-compile your application,
as far as I understand it.
2. Use the toolchain. If you write a piece of code (like the famous hello world
program for starters :), you want to "cross-compile it. So something like
$ arm-linux-gcc -Wall -o hello hello.c
will produce an executable for arm, check the output of
$ file hello
Now since this is tedious, you will almost certainly end up, making changes to your
build process. E.g. add
CC = arm-linux-gcc
into your makefile. arm-linux-gcc will normally use the correct libraries for linking.
If it doesn't, switches like
-L/usr/arm-linux/lib
in the compile/link commands would help.
3. Add the newly compiled programm to the world of your target board by any of these:
- adding it to the root-file-system part of the boot image and reboot
- setting up your target to mount an nfs root file system, and copy it over.
- transfer the program while the target is up via ftp, scp or so
and
4. run the programm.
step 3 is more complicated IFF your programm uses dynamically loaded libraries. Then you
must copy over any needed libraries and use a few ld-config calls/or LD_LIBRARY_PATH
settings to make the dynamical loader on the target aware of the new libs.
I have used this process successfully for a toolchain on intel, producing code
for an ARM target (based on the NetSilicon 9750 chip)
Please note: I write this down from my head, no toolchain at my fingertips, so file
names and other details may be incorrect.
If you need a worked example, check out Karim Yaghmour's book
"Building Embedded Linux Systems" O'Reilly, ISBN: 0-596-00222-X
To get a first feeling for all of this, I suggest to get hold of both a powerpc and an
intel system (or any two different architectures available to you) --- both fully equipped
with GNU/Linux, network and all the nice things. Then take the intel box and set up a
toolchain for powerpc. This makes testing the compiled code simpler.
Hope this helps!
Cheers,
Erich
Reply to: