C: Difference between revisions
imported>Mic92 typo |
imported>Mic92 short passage about cross-compiling |
||
Line 177: | Line 177: | ||
[nix-shell:~] $ cmake . | [nix-shell:~] $ cmake . | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== Cross-Compiling == | |||
To get access to a cross-compiling toolchain use `pkgsCross` prefix. | |||
In this example we load the compiler for the arm-embedded target (bare metal without operating system): | |||
<syntaxHighlight lang=nix> | |||
with import <nixpkgs> {}; | |||
pkgsCross.arm-embedded.stdenv.mkDerivation { | |||
name = "env"; | |||
} | |||
</syntaxHighlight> | |||
This will set build environment variables like <code>$CC</code>, <code>$AR</code> and <code>$LD</code>: | |||
<syntaxHighlight lang=console> | |||
$ echo $CC $AR $CXX $LD | |||
arm-none-eabi-gcc arm-none-eabi-ar arm-none-eabi-g++ arm-none-eabi-ld | |||
</syntaxHighlight> | |||
Well behaved build systems should respect these environment variables when building projects. | |||
Also take a look in the [[Cross Compiling]] article for further information on cross-compiling. |