GCC Cross-Compiler: Difference between revisions

Jump to navigation Jump to search
convert first- and second- person pronouns
[unchecked revision][unchecked revision]
(Fix spelling error)
(convert first- and second- person pronouns)
Line 1:
{{FirstPerson}}
{{rating|1}}
This tutorial focuses on creating a GCC cross-compiler for your own operating system. This compiler that we build here will have a generic target (i686-elf) whatthat allows you to leave the current operating system behind, meaning that no headers or libraries of yourthe host operating system will be used. YouWithout ''need''using a cross-compiler for operating system development, otherwise a lot of unexpected things can happen because the compiler assumes that yourthe code is running on yourthe host operating system.
 
== Introduction ==
 
Generally speaking, a cross-compiler is a compiler that runs on platform A (the '''host'''), but generates executables for platform B (the '''target'''). These two platforms may (but do not need to) differ in CPU, operating system, and/or [[:Category:Executable Formats|executable format]]. In our case, the host platform is your current operating system and the target platform is the operating system you are about to make. It is important to realize that these two platforms are not the same; the operating system you are developing is always going to be different from the operating system you currently use. This is why we need to build a cross-compiler first, you will most certainly run into trouble otherwise.
 
=== Why cross-compilers are necessary ===
{{Main|Why do I need a Cross Compiler?}}
 
You need to use a cross-compiler ''unless'' you are developing on your own operating system. The compiler must know the correct target platform (CPU, operating system), otherwise you will run into trouble. If you use theThe compiler that comes with yourthe host system, thendoes thenot compilerknow won'tby knowdefault that it is compiling something else entirely., Some tutorials suggest using your system compiler and passingunless a lot of problematic options are passed to theit, compiler. Thiswhich will certainly give youcreate a lot of problems in the future. and theThe solution is build a cross-compiler. If you have already attempted to make an operating system without usingbuild a cross-compiler, please read the article [[Why do I need a Cross Compiler?]].
 
=== Which compiler version to choose ===
{{Main|Building GCC}}
 
The newest [[GCC]] is recommended as it is the latest and greatest release. For instance, you may run into trouble if you useusing GCC 4.6.3 to build a GCC 4.8.0 cross-compiler. Ifwould youcreate aretroubles. notHere usingis thehow latest major GCC release for your system compiler, we recommend that youto [[Building GCC|build the newest GCC as your system compiler]].
 
You can also use older releases as they are usually reasonably good. If your local system compiler isn't too terribly old (at least GCC 4.6.0), you may wish to save yourself the trouble and just pick the latest minor release (such as 4.6.3 if your system compiler is 4.6.1) for your cross-compiler.
 
YouThis cancommand viewprints yourthe current compiler version by invoking:
 
<source lang="bash">gcc --version</source>
Line 27:
=== Which binutils version to choose ===
{{Main|Cross-Compiler Successful Builds}}
We recommend that you use theThe latest and greatest [[Binutils]] release is recommended. Note, however, that not all combinations of GCC and Binutils work. If you run into trouble, use a Binutils that was released at roughly the same time as your desired compiler version. You probably need at least Binutils 2.22, or preferably the latest 2.23.2 release. It doesn't matter what Binutils version you have installed on your current operating system. YouThis cancommand find outprints the binutils version for example by this command:
<source lang="bash">ld --version</source>
 
9

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu