Next: Renaming Programs at Install Time, Previous: Two-Part Installation, Up: Use Cases for the GNU Build System [Contents][Index]
To cross-compile is to build on one platform a binary that will
run on another platform. When speaking of cross-compilation, it is
important to distinguish between the build platform on which
the compilation is performed, and the host platform on which the
resulting executable is expected to run. The following
configure
options are used to specify each of them:
The system on which the package is built.
The system where built programs and libraries will run.
When the --host is used, configure
will search for
the cross-compiling suite for this platform. Cross-compilation tools
commonly have their target architecture as prefix of their name. For
instance my cross-compiler for MinGW32 has its binaries called
i586-mingw32msvc-gcc
, i586-mingw32msvc-ld
,
i586-mingw32msvc-as
, etc.
Here is how we could build amhello-1.0
for
i586-mingw32msvc
on a GNU/Linux PC.
~/amhello-1.0 % ./configure --build i686-pc-linux-gnu --host i586-mingw32msvc checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for i586-mingw32msvc-strip... i586-mingw32msvc-strip checking for i586-mingw32msvc-gcc... i586-mingw32msvc-gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... yes checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether i586-mingw32msvc-gcc accepts -g... yes checking for i586-mingw32msvc-gcc option to accept ANSI C... … ~/amhello-1.0 % make … ~/amhello-1.0 % cd src; file hello.exe hello.exe: MS Windows PE 32-bit Intel 80386 console executable not relocatable
The --host and --build options are usually all we need for cross-compiling. The only exception is if the package being built is itself a cross-compiler: we need a third option to specify its target architecture.
When building compiler tools: the system for which the tools will create output.
For instance when installing GCC, the GNU Compiler Collection, we can use --target=TARGET to specify that we want to build GCC as a cross-compiler for TARGET. Mixing --build and --target, we can actually cross-compile a cross-compiler; such a three-way cross-compilation is known as a Canadian cross.
See Specifying the System Type in The
Autoconf Manual, for more information about these configure
options.
Next: Renaming Programs at Install Time, Previous: Two-Part Installation, Up: Use Cases for the GNU Build System [Contents][Index]