Fundamentals 6 min read

Copy‑Paste Setup: Build an ARM32/ARM64 Cross‑Compile Environment on Ubuntu

This guide walks through installing all required packages, configuring ARM32 and ARM64 cross‑compilation toolchains on Ubuntu 18.04/20.04/22.04, verifying the setup with a sample program, and provides commands for fixing common issues and uninstalling the toolchains.

Deepin Linux
Deepin Linux
Deepin Linux
Copy‑Paste Setup: Build an ARM32/ARM64 Cross‑Compile Environment on Ubuntu

This tutorial targets Ubuntu 18.04, 20.04 and 22.04 and demonstrates how to create a complete ARM32 and ARM64 cross‑compilation environment that can build ARM programs, kernels and drivers on an x86_64 host.

Update package sources and upgrade the system to avoid later dependency errors: sudo apt update && sudo apt upgrade -y Install the basic compilation dependencies that cover most ARM build scenarios:

sudo apt install -y build-essential libc6-dev \
    bison flex libssl-dev \
    libncurses5-dev git make cmake automake autoconf libtool pkg-config

The build-essential package provides gcc, g++, make and related tools; bison and flex are needed for kernel‑related parsing; libssl-dev supplies cryptographic headers.

Install the ARM cross‑compilation toolchains . The guide distinguishes between ARM32 (32‑bit) and ARM64 (AArch64) and shows the commands for each. After installation, source the profile to make the new tools available: source /etc/profile Verify the environment by generating a simple test source file and compiling it with both toolchains:

echo '#include <stdio.h>
int main(){
    printf("ARM Cross Compile Success!
");
    return 0;
}' > test.c
# ARM32 cross‑compile
arm-linux-gnueabihf-gcc test.c -o test_arm32
# ARM64 cross‑compile
aarch64-linux-gnu-gcc test.c -o test_arm64
# Check the binaries
file test_arm32 test_arm64

The file command should report test_arm32 as an ARM32 binary and test_arm64 as an AArch64 binary, confirming that the toolchains work correctly.

If dependency problems or compilation errors occur, the following repair steps are suggested:

# Fix missing dependencies
sudo apt -f install -y
# Reconfigure package database
sudo dpkg --configure -a
# Reinstall the toolchains
sudo apt reinstall gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu -y

To completely remove the toolchains, use:

# Remove ARM32 toolchain
sudo apt remove -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
# Remove ARM64 toolchain
sudo apt remove -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

With these commands, the tutorial provides a zero‑configuration, copy‑and‑paste solution for setting up, validating, troubleshooting, and optionally uninstalling an ARM cross‑compilation environment on mainstream Ubuntu releases.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxARMToolchaingccUbuntucross-compilation
Deepin Linux
Written by

Deepin Linux

Research areas: Windows & Linux platforms, C/C++ backend development, embedded systems and Linux kernel, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.