
Cross Gcc
- 412 installs
- 155 repo stars
- Updated June 27, 2026
- mohitmishra786/low-level-dev-skills
Cross GCC is an agent skill that configures GCC cross-compilers and sysroots to build ARM, embedded, or foreign-architecture binaries for developers who compile from a host workstation or CI pipeline.
About
Cross GCC is an agent skill from mohitmishra786/low-level-dev-skills that guides setup of GCC cross-compilers and sysroots for non-native targets. The workflow covers toolchain selection, sysroot layout, and build flags so ARM, embedded, or other foreign-architecture binaries compile from a developer machine or CI runner. Developers reach for Cross GCC when porting low-level code to embedded boards or heterogeneous build farms. Cross GCC fits teams shipping firmware, drivers, or bare-metal services that cannot rely on the host architecture compiler alone.
- Target triple selection
- Sysroot and linker flags
- CMake/autotools cross files
- CI reproducible builds
- Multilib and ABI pitfalls
Cross Gcc by the numbers
- 412 all-time installs (skills.sh)
- +28 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #292 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill cross-gccAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 412 |
|---|---|
| repo stars | ★ 155 |
| Last updated | June 27, 2026 |
| Repository | mohitmishra786/low-level-dev-skills ↗ |
How do you configure GCC cross-compilers for ARM builds?
Configure GCC cross-compilers and sysroots to build ARM, embedded, or foreign-arch binaries from a host CI or developer workstation.
Who is it for?
Developers and platform engineers targeting ARM, embedded, or non-host architectures who need GCC cross-compiler and sysroot setup on CI or local workstations.
Skip if: Pure web or mobile app teams compiling only for the host OS without embedded or cross-architecture binary requirements.
When should I use this skill?
A project must compile ARM, embedded, or foreign-architecture binaries and the GCC cross-compiler or sysroot is not yet configured.
What you get
Cross-compiler toolchain configuration, sysroot layout, and foreign-architecture build commands
- Cross-compiler configuration
- Sysroot setup commands
Files
Cross-GCC
Purpose
Guide agents through setting up and using cross-compilation GCC toolchains: triplets, sysroots, pkg-config, QEMU-based testing, and common failure modes.
Triggers
- "How do I compile for ARM on my x86 machine?"
- "I'm getting 'wrong ELF class' or 'cannot execute binary file'"
- "How do I set up a sysroot for cross-compilation?"
- "pkg-config returns host libraries in my cross build"
- "How do I debug a cross-compiled binary with QEMU + GDB?"
Workflow
1. Understand the triplet
A GNU triplet has the form <arch>-<vendor>-<os>-<abi> (often 3 or 4 parts):
| Triplet | Target |
|---|---|
aarch64-linux-gnu | 64-bit ARM Linux (glibc) |
arm-linux-gnueabihf | 32-bit ARM Linux hard-float |
arm-none-eabi | Bare-metal ARM (no OS) |
riscv64-linux-gnu | 64-bit RISC-V Linux |
x86_64-w64-mingw32 | Windows (MinGW) from Linux |
mipsel-linux-gnu | Little-endian MIPS Linux |
2. Install the toolchain
# Debian/Ubuntu
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
# For bare-metal ARM (Cortex-M)
sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi
# Verify
aarch64-linux-gnu-gcc --version3. Basic cross-compilation
# C
aarch64-linux-gnu-gcc -O2 -o hello hello.c
# C++
aarch64-linux-gnu-g++ -O2 -std=c++17 -o hello hello.cpp
# Bare-metal (no stdlib, no OS)
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-ffreestanding -nostdlib -T linker.ld -o firmware.elf startup.s main.c4. Sysroot
A sysroot is a directory containing the target's headers and libraries. Required when your code links against target-specific libraries.
# Use a sysroot
aarch64-linux-gnu-gcc --sysroot=/path/to/aarch64-sysroot -O2 -o prog main.c
# Common sysroot sources:
# - Raspberry Pi: download from raspbian/raspios
# - Debian multiarch: debootstrap --arch arm64 bullseye /tmp/sysroot
# - Yocto/Buildroot: generated automatically in build outputVerify the sysroot is correct:
aarch64-linux-gnu-gcc --sysroot=/path/to/sysroot -v -E - < /dev/null 2>&1 | grep sysroot5. pkg-config for cross builds
pkg-config will return host library paths by default. Override:
export PKG_CONFIG_SYSROOT_DIR=/path/to/sysroot
export PKG_CONFIG_LIBDIR=${PKG_CONFIG_SYSROOT_DIR}/usr/lib/aarch64-linux-gnu/pkgconfig:${PKG_CONFIG_SYSROOT_DIR}/usr/share/pkgconfig
export PKG_CONFIG_PATH= # clear host path
pkg-config --libs libssl # now returns target paths6. CMake cross-compilation
Create a toolchain file aarch64.cmake:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_SYSROOT /path/to/aarch64-sysroot)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=aarch64.cmake
cmake --build build7. Test with QEMU
# User-mode emulation (Linux binaries, no full OS)
sudo apt install qemu-user-static
qemu-aarch64-static ./hello
# Or set binfmt_misc for transparent execution:
# Then just: ./hello
# GDB remote debug via QEMU
qemu-aarch64-static -g 1234 ./hello &
aarch64-linux-gnu-gdb -ex "target remote :1234" ./hello8. Common errors
| Error | Cause | Fix |
|---|---|---|
cannot execute binary file: Exec format error | Running target binary on host without QEMU | Use qemu-<arch>-static |
wrong ELF class: ELFCLASS64 (or 32) | Wrong-architecture object linked | Check triplet; ensure all objects use same toolchain |
/usr/bin/ld: cannot find -lfoo | Host library path used for cross-link | Set --sysroot; fix PKG_CONFIG_LIBDIR |
undefined reference to '__aeabi_*' | Missing ARM ABI runtime | Link with -lgcc or -lclang_rt.builtins |
relocation R_AARCH64_ADR_PREL_PG_HI21 out of range | Distance too large | Use -mcmodel=large or restructure |
unrecognized opcode | Wrong -mcpu or -march | Set correct CPU flags for target |
9. Environment variables
# Tell build systems to use cross-compiler
export CC=aarch64-linux-gnu-gcc
export CXX=aarch64-linux-gnu-g++
export AR=aarch64-linux-gnu-ar
export STRIP=aarch64-linux-gnu-strip
export OBJDUMP=aarch64-linux-gnu-objdump
# For autoconf projects
./configure --host=aarch64-linux-gnu --prefix=/usrFor a reference on ARM-specific GCC flags, see references/arm-flags.md.
Related skills
- Use
skills/compilers/gccfor GCC flag details - Use
skills/debuggers/gdbfor remote debugging withgdbserver - Use
skills/low-level-programming/assembly-armfor AArch64 assembly specifics - Use
skills/build-systems/cmakefor toolchain file setup
ARM / AArch64 GCC Flags Reference
Source: <https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html> Source: <https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html>
AArch64 (64-bit ARM)
| Flag | Effect |
|---|---|
-march=armv8-a | ARMv8-A baseline |
-march=armv8.2-a+fp16 | ARMv8.2 + FP16 |
-mcpu=cortex-a72 | Tune for Cortex-A72 |
-mcpu=native | Detect host CPU (for native AArch64 builds) |
-moutline-atomics | Outline atomic operations for better LSE compatibility |
32-bit ARM
| Flag | Effect |
|---|---|
-march=armv7-a | ARMv7-A (Cortex-A series) |
-march=armv7-m | ARMv7-M (Cortex-M3/M4) |
-mcpu=cortex-m4 | Tune for Cortex-M4 |
-mthumb | Thumb instruction set (16/32-bit mixed) |
-mthumb-interwork | Allow switching between ARM and Thumb |
-mfloat-abi=soft | Software FP emulation |
-mfloat-abi=softfp | HW FPU, soft-float ABI (pass floats in int regs) |
-mfloat-abi=hard | HW FPU, hard-float ABI (pass floats in FP regs) |
-mfpu=fpv4-sp-d16 | Cortex-M4 FPU (single precision) |
-mfpu=fpv5-d16 | Cortex-M7 FPU (double precision) |
-mfpu=neon | NEON SIMD |
-mfpu=neon-vfpv4 | NEON + VFPv4 |
Bare-metal / embedded
arm-none-eabi-gcc \
-mcpu=cortex-m4 \
-mthumb \
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
-ffreestanding \
-nostdlib \
-nostartfiles \
-T linker.ld \
-o firmware.elf \
startup.s main.cKey flags explained:
-ffreestanding: no hosted C library assumed-nostdlib: don't link standard libraries-nostartfiles: don't use standard startup files (crt0.o, etc.)-T linker.ld: use custom linker script
RISC-V
| Flag | Effect |
|---|---|
-march=rv64gc | 64-bit, general + compressed + float |
-march=rv32imc | 32-bit, int + multiply + compressed |
-mabi=lp64d | 64-bit LP64 with double FP |
-mabi=ilp32 | 32-bit ILP32, soft FP |
-mcpu=sifive-u74 | SiFive U74 core |
Related skills
FAQ
What targets does Cross GCC help build for?
Cross GCC helps configure GCC toolchains and sysroots for ARM, embedded, and other foreign-architecture binaries. Builds run from a host developer workstation or CI environment instead of on the target device.
When should developers use Cross GCC?
Cross GCC fits pre-build toolchain setup when native host compilers cannot produce firmware or embedded binaries. Use it to define sysroots, compiler prefixes, and flags before compiling low-level code.