You can force a version:

apt-get install gcc-arm-linux-gnueabihf=4:9.3.0-1ubuntu2

From man apt-get: install pkg [{=pkg_version_number | /target_release}]...

Answer from user.dz on askubuntu.com
🌐
Arm Developer
developer.arm.com › downloads › - › arm-gnu-toolchain-downloads
Arm GNU Toolchain Downloads – Arm Developer
AArch32 GNU/Linux target with hard float (arm-none-linux-gnueabihf) arm-gnu-toolchain-15.2.rel1-mingw-w64-x86_64-arm-none-linux-gnueabihf.zip · arm-gnu-toolchain-15.2.rel1-mingw-w64-x86_64-arm-none-linux-gnueabihf.zip.asc · arm-gnu-toolchain-15.2.rel1-mingw-w64-x86_64-arm-none-linux-gnueabihf.zip.sha256asc ·
🌐
GitHub
github.com › eckucukoglu › arm-linux-gnueabihf
GitHub - eckucukoglu/arm-linux-gnueabihf: gcc version: 4.9.2, glibc version: 2.19, binutils version: 2.24, gdb version: 7.6.1, kernel headers version: 199248 (3.10.80) · GitHub
gcc version: 4.9.2, glibc version: 2.19, binutils version: 2.24, gdb version: 7.6.1, kernel headers version: 199248 (3.10.80) - eckucukoglu/arm-linux-gnueabihf
Starred by 9 users
Forked by 2 users
Languages   Python 40.8% | HTML 25.7% | C 15.8% | C++ 10.7% | Roff 3.5% | Perl 1.2%
Top answer
1 of 1
1

You can run arm-linux-gnueabihf-gcc-5 instead of gcc.

This file list includes the names of the other tools the gcc-5-arm-linux-gnueabihf package places in /usr/bin, which you may find useful. (You didn't mention what release you're running but I'm guessing it's 18.04, since that release is a popular LTS and it defaults to version 7.)

Note that even if you wanted to use the default version, unless you've changed what /usr/bin/gcc points to (which I don't recommend), the gcc command is running a GCC compiler that generates native executables. This won't be an ARM compiler unless your Ubuntu system is running on ARM. To run the default version of the GCC cross compiler for armhf, use arm-linux-gnueabihf-gcc (and see this file list).

Multiple versions of both native and cross compilers can be installed on the same system at the same time. Only the default version of the native GCC compiler is typically invoked with the gcc command, however. Other commands have a toolchain prefix, a version suffix, or (in this case) both. This is the case even when that non-default compiler is the only compiler installed on the system.

If you really must make gcc call that compiler...

If you need gcc to call that compiler because some other build tool, like make is calling gcc, the best approach is usually to reconfigure that other tool or to set the CC environment variable to the compiler you want. Just making gcc run the compiler you need may also not be sufficient, because the names of other tools will still run the native versions.

With that said, assuming your your Ubuntu system is not an armhf system but you still really want gcc to run the arm-linux-gnueabihf-gcc-5 cross compiler, you have a few options. You could replace the /usr/bin/gcc symlink (which on 18.04 links to gcc-7), but I recommend against that. Doing that is likely to break anything that assumes gcc is a native compiler, and may either interfere with or be undone by future package management operations.

Instead, you could put a gcc symlink to arm-linux-gnueabihf-gcc-5 in your user's private bin directory ~/bin. The default per-user ~/.profile file adds that directory to $PATH when you log in, if the directory exists. Automated builds (like when you run ./configure or cmake .. and then make) that you don't customize usually use cc, which will continue to be a symlink to a native compiler, so this shouldn't break things.

Personally, I would not want to do even this, because I would myself become confused. I prefer that it always be immediately clear what platform my compiler targets, when it is a cross compiler.

🌐
Ubuntu
launchpad.net › ubuntu › focal › amd64 › gcc-arm-linux-gnueabihf › 4:9.3.0-1ubuntu2
4:9.3.0-1ubuntu2 : gcc-arm-linux-gnueabihf : amd64 : Focal (20.04) : Ubuntu
gcc-arm-linux-gnueabihf · 4:9.3.0-1ubuntu2 · This is the GNU C compiler, a fairly portable optimizing compiler for C. . This is a dependency package providing the default GNU C cross-compiler for the armhf architecture.
🌐
Debian
packages.debian.org › sid › gcc-arm-linux-gnueabihf
Debian -- Details of package gcc-arm-linux-gnueabihf in sid
dep: cpp-arm-linux-gnueabihf (= 4:15.2.0-5+b1) GNU C preprocessor (cpp) for the armhf architecture · dep: gcc-15-arm-linux-gnueabihf (>= 15.2.0-2~) GNU C compiler for the arm-linux-gnueabihf architecture · rec: libc-dev [armhf] Package not available · rec: libc6-dev [armhf] GNU C Library: Development Libraries and Header Files also a virtual package provided by libc6.1-dev ·
🌐
Acmesystems
acmesystems.it › arm9_toolchain
Install the ARM cross compiler toolchain on your Linux PC
arm-linux-gnueabihf-g++ hello.cc -o hello · As you can see we are using the ARM version of gcc just installed on your PC. It will generate an executable class='acmetable' file for your Linux board. Copy the executable class='acmetable' file on the board via ssh: scp hello root@[your_board_ip]:/root ·
Find elsewhere
🌐
Debian
packages.debian.org › gcc-arm-linux-gnueabihf
Debian -- Package Search Results -- gcc-arm-linux-gnueabihf
experimental (devel): GNU C compiler for the armhf architecture 4:16-20251130-1: amd64 arm64 armhf i386 ppc64el s390x x32
🌐
GitHub
gist.github.com › process1183 › e224240df18483e57fa2872fb4d89023
Version information from Debian's gcc-arm-linux-gnueabi and gcc-arm-linux-gnueabihf packages · GitHub
Version information from Debian's gcc-arm-linux-gnueabi and gcc-arm-linux-gnueabihf packages - debian-gcc-arm-linux-gnueabi-versions.txt
🌐
Arm Developer
developer.arm.com › downloads › - › gnu-a
Downloads | GNU-A Downloads – Arm Developer
The following executables in the Windows hosted toolchains: - aarch64-none-linux-gnu-dwp.exe - aarch64-none-linux-gnu-ld.gold.exe - arm-none-linux-gnueabihf-dwp - arm-none-linux-gnueabihf-ld.gold.exe have additional dependencies on the following dlls: - libwinpthread-1.dll - libgcc_s_sjlj-1.dll - libstdc++-6.dll - libgcc_s_dw2-1.dll You can obtain the required dlls from the MinGW-W64 GCC-8.1.0 packages from SourceForge: - i686-posix-sjlj - i686-posix-dwarf · The package names of the released GNU toolchain binaries have the following naming convention: gcc-arm-<Release Version>-<Host>-<Target Triple>.tar.xz
🌐
Arch Linux
aur.archlinux.org › packages › arm-linux-gnueabihf-gcc
AUR (en) - arm-linux-gnueabihf-gcc
(1/1) checking for file conflicts [###########################################] 100% error: failed to commit transaction (conflicting files) arm-linux-gnueabihf-gcc: /usr/share/gcc-14.2.1/python/libstdcxx/__init__.py exists in filesystem (owned by gcc) arm-linux-gnueabihf-gcc: /usr/share/gcc-14.2.1/python/libstdcxx/v6/__init__.py exists in filesystem (owned by gcc) arm-linux-gnueabihf-gcc: /usr/share/gcc-14.2.1/python/libstdcxx/v6/printers.py exists in filesystem (owned by gcc) arm-linux-gnueabihf-gcc: /usr/share/gcc-14.2.1/python/libstdcxx/v6/xmethods.py exists in filesystem (owned by gcc)
🌐
Ubuntu
launchpad.net › ubuntu › focal › arm64 › gcc-9-arm-linux-gnueabihf › 9.3.0-8ubuntu1cross2
9.3.0-8ubuntu1cross2 : gcc-9-arm-linux-gnueabihf : arm64 : Focal (20.04) : Ubuntu
gcc-9-arm-linux-gnueabihf · 9.3.0-8ubuntu1cross2 · This is the GNU C compiler, a fairly portable optimizing compiler for C. . This package contains C cross-compiler for armhf architecture.
🌐
GitHub
github.com › crux-arm › crux-toolchain-arm-linux-gnueabihf
GitHub - crux-arm/crux-toolchain-arm-linux-gnueabihf: CRUX-ARM Toolchain using hard-float version of the "new" ABI (EABI), targeting armv7 and up · GitHub
CRUX-ARM Toolchain using hard-float version of the "new" ABI (EABI), targeting armv7 and up - crux-arm/crux-toolchain-arm-linux-gnueabihf
Author   crux-arm
🌐
Arm Community
community.arm.com › support-forums › f › compilers-and-libraries-forum › 12062 › windows-version-of-arm-linux-gnueabi-and-arm-linux-gnueabihf-for-gcc8
Windows version of arm-linux-gnueabi and ...
Have a question about working on Arm technology? Browse our support forums for solutions to your questions, answer questions from fellow community members and get help from Arm experts.
🌐
GitHub
github.com › Philon › arm-mac-linux-gnueabihf
GitHub - philon/macos-crosstools: arm-linux cross toolchains for macOS · GitHub
GCC Version: 10.3.0 Build: MacBook Air with m1 Host: arm64-apple-darwin20.4.0 Target: ARMv7/Cortex-A15(hardware float) Language: c/c++ Using built-in specs. COLLECT_GCC=/opt/arm-mac-linux-gnueabihf/bin/arm-mac-linux-gnueabihf-gcc COLLECT_LT...
Starred by 36 users
Forked by 11 users
Languages   C++ 50.6% | C 47.9% | Python 1.0% | Shell 0.3% | XC 0.1% | XS 0.1%
🌐
Duetorun
duetorun.com › blog › 20230401 › arm-toolchain
Arm GNU Toolchain - ElseWhere
Done gcc-arm-linux-gnueabihf/jammy 4:11.2.0-1ubuntu1 arm64 GNU C compiler for the armhf architecture · $ apt search -n gcc-aarch64-linux-gnu Sorting... Done Full Text Search... Done $ apt search -n gcc Sorting... Done Full Text Search...
🌐
Fedora
copr.fedorainfracloud.org › coprs › lantw44 › arm-linux-gnueabihf-toolchain
lantw44/arm-linux-gnueabihf-toolchain Copr
Latest version of GNU Binutils, GCC, GLIBC which support cross-compiling for GNU/Linux running on 32-bit ARMv7 CPU with hardware floating point. Binaries built by this toolchain should be able to run on Fedora ARM. RPM specs for this project is maintained in the same repository as ...
🌐
Homebrew
formulae.brew.sh › formula › arm-linux-gnueabihf-binutils
arm-linux-gnueabihf-binutils — Homebrew Formulae
Formula code: arm-linux-gnueabihf-binutils.rb on GitHub · Bottle (binary package) installation support provided for: Current versions: Depends on: Depends on when building from source: Requires: macOS >= 13 ·