GCC Cross-Compiler on Gentoo Linux

From OSDev Wiki

(Redirected from GCC Cross-Compiler on Linux)
Jump to: navigation, search

Gentoo, being a source-based distribution, makes it almost ridiculously easy to set up a cross-development toolchain:

   emerge crossdev
   crossdev --stage1 --binutils <binutils-version> --gcc <gcc-version> --target <target>

This will install a GCC cross-compiler into a "slot", i.e. alongside already-existing compiler versions. You can install several cross-compilers that way, simply by changing target designations.

You can now use your cross-compiler, either by calling <target>-gcc, or by setting the cross-compiler as "active" compiler using gcc-config (but remember to reset it to the default setting before you do the next emerge).

You can uninstall the cross-compiler by calling crossdev --clean <target>. Read the cross-development document for additional information.

Note that the version numbers to binutils and gcc are Gentoo package versions, i.e. there might be a suffix to the "official" (GNU) version that addresses additional patchsets supplied by the Gentoo maintainers. (For example, --binutils 2.16.1-r3 --gcc 4.1.1-r3 is the latest stable package pair at the time of this writing.) You can omit the version numbers to use the latest package available.

Personal tools