The network has a lot of sources on the subject of building applications for the ARM architecture, but when I first encountered this task, I crammed more than one lump. This topic will be about the very beginnings of cross-compilation and various approaches to this issue.
My device belongs to the ARMv5TE architecture and development was carried out on an x86 machine with Ubuntu Linux.
Since this is an introduction, we will collect a simple
program for calculating the factorial of a number.
Approach 1. Commercial.
CodeSourcery produces Sourcery G ++, a commercial integrated development environment based on GNU tools (gcc, gdb, binutils) and having an Eclipse-based interface. Perhaps this is the easiest and fastest way to create applications, since during installation all the necessary libraries and the crosscompiler are installed. On the official
website, in addition to the possibility of purchase, you can use the trial version for 30 days. Due to the close relationship with Eclipse, the settings are intuitive and there is no point in writing in detail.
')
For one-time tasks is ideal, but there are absolutely free solutions.
Approach 2. QEMU.
The well-known
QEMU emulation program also supports the ARM platform, which is a sin not to take advantage of.
First, install the program itself:
sudo apt-get install qemu-kvm-extras-static
The QEMU developers made a separate command for easy installation of the environment (in my case this is debian lenny):
sudo build-arm-chroot lenny qemu
As a result, we will create a qemu directory with an image of the lenny system for the architecture we need.
Not enough network and necessary packages to compile. Edit the sources.list of our qemu machine:
sudo nano qemu/etc/apt/sources.list
And add there
deb ftp.us.debian.org/debian lenny main contrib non-free
deb-src ftp.us.debian.org/debian lenny main contrib non-free
We update, install the necessary packages and assemble our factorial in QEMU itself.
Approach 3. Collect crosstool.
Crosstool is a set of scripts for building and testing gcc and glibc for all the architectures supported by glibc. When assembling various crosstula (one
way or another), I had problems with the compatibility of various components. So, for example, gcc was not friendly with binutils due to the difference in versions and it was necessary to select working bundles using a random method. Fortunately, this process has already been automated and made extremely simple. What thanks to the user of the site linux.org.ru
mskmsk1985 :
The
script he wrote collects the toolchain for the arm-linux-gnueabi- architecture from the latest versions of GNU tools. C and C ++ cross compilers, a cross debugger, and a debug server for the target architecture are assembled. Read more
here .
Approach 4. Gentoo-way.
As I wrote, it was all collected on a computer with Ubuntu, but it is worth saying that Gentoo has a separate
crossdev program that does the same thing and collects binaries for the desired architecture.
Approach 5. Ubuntu-way.
My long search for the easiest way to cross-compilation was very confusing and, of course, I missed a solution that was too obvious and simple to even think about. But it turned out that yes, the crosscompiler can be supplied from repositories with one command:
sudo apt-get install libc6-dev-armel-cross gcc-arm-linux-gnueabi
Instead of a conclusion.
Cross-compilation methods are not limited to the examples given above. There are multi-page descriptions, options for creating the necessary 'from scratch' tools, but if you need to quickly write and run a simple application on a different architecture, there is often not enough time to fully study, and the number of nuances and software incompatibilities can discourage any desire to do this.
I hope my short review will help you to avoid my mistakes and quickly get a working tool for creating an application on the ARM-architecture. Good luck!