Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Cross compiler
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== GCC and cross compilation == [[GNU Compiler Collection|GCC]], a [[free software]] collection of compilers, can be set up to cross compile. It supports many platforms and languages. GCC requires that a compiled copy of [[binutils]] is available for each targeted platform. Especially important is the [[GNU Assembler]]. Therefore, binutils first has to be compiled correctly with the switch <code>--target=some-target</code> sent to the [[configure script]]. GCC also has to be [[configure script|configured]] with the same <code>--target</code> option. GCC can then be run normally provided that the tools, which [[binutils]] creates, are available in the [[Path (computing)|path]], which can be done using the following (on UNIX-like operating systems with bash): PATH=/path/to/binutils/bin:${PATH} make Cross-compiling GCC requires that a portion of the ''target platform'''s [[C standard library]] be available on the ''host platform''. The programmer may choose to compile the full C library, but this choice could be unreliable. The alternative is to use [[newlib]], which is a small [[C library]] containing only the most essential components required to compile [[C (programming language)|C]] source code. <!-- To configure GCC with newlib, use the switch <code>--with-newlib</code>. --> The [[GNU Autotools]] packages (i.e. [[autoconf]], [[automake]], and [[libtool]]) use the notion of a ''build platform'', a ''host platform'', and a ''target platform''. The ''build platform'' is where the compiler is actually compiled. In most cases, build should be left undefined (it will default from host). The ''host platform'' is always where the output artifacts from the compiler will be executed whether the output is another compiler or not. The ''target platform'' is used when cross-compiling cross compilers, it represents what type of object code the package will produce; otherwise the ''target platform'' setting is irrelevant.<ref>{{Cite web|url=https://www.gnu.org/s/libtool/manual/automake/Cross_002dCompilation.html|title=Cross-Compilation (Automake)}}</ref> For example, consider cross-compiling a video game that will run on a [[Dreamcast]]. The machine where the game is compiled is the ''build platform'' while the Dreamcast is the ''host platform''. The names ''host'' and ''target'' are relative to the compiler being used and shifted like ''son'' and ''grandson''.<ref>{{Cite web|url=https://mesonbuild.com/Cross-compilation.html|title=Cross compilation}}</ref> Another method popularly used by embedded Linux developers involves the combination of GCC compilers with specialized sandboxes like [[Scratchbox]] and [[Scratchbox 2]], or [https://proot-me.github.io/ PRoot]. These tools create a "[[chroot]]ed" sandbox where the programmer can build up necessary tools, libc, and libraries without having to set extra paths. Facilities are also provided to "deceive" the runtime so that it "believes" it is actually running on the intended target CPU (such as an ARM architecture); this allows configuration scripts and the like to run without error. Scratchbox runs more slowly by comparison to "non-chrooted" methods, and most tools that are on the host must be moved into Scratchbox to function.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)