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
🌐
Debian
packages.debian.org › sid › gcc-arm-linux-gnueabihf
Debian -- Details of package gcc-arm-linux-gnueabihf in sid
gcc-mipsel-linux-gnu · 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. dep: cpp-arm-linux-gnueabihf (= 4:15.2.0-5+b1) GNU C preprocessor (cpp) for the armhf architecture ·
Debian Packages Search
This site provides you with information about all the packages available in the Debian Package archive · Please contact Debian Webmaster if you encounter any problems
Debian -- Package Search Results -- stable
Limit to suite: [bullseye] [bullseye-updates] [bullseye-backports] [bookworm] [bookworm-updates] [bookworm-backports] [trixie] [trixie-updates] [trixie-backports] [forky] [sid] [experimental] · Limit to a architecture: [alpha] [amd64] [arm] [arm64] [armel] [armhf] [avr32] [hppa] [hurd-i386] ...
List of sections in "bookworm"
Limit to suite: [bullseye] [bullseye-updates] [bullseye-backports] [bookworm] [bookworm-updates] [bookworm-backports] [trixie] [trixie-updates] [trixie-backports] [forky] [sid] [experimental] · Limit to a architecture: [alpha] [amd64] [arm] [arm64] [armel] [armhf] [avr32] [hppa] [hurd-i386] ...
🌐
Debian
packages.debian.org › buster › gcc-arm-linux-gnueabihf
Details of package gcc-arm-linux-gnueabihf in buster
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Debian
packages.debian.org › buster › gcc-8-arm-linux-gnueabihf
Package: gcc-8-arm-linux-gnueabihf (8.3.0-2cross1)
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Debian
packages.debian.org › stretch › gcc-arm-linux-gnueabihf
Debian -- Error
two or more packages specified (gcc-arm-linux-gnueabihf stretch) See our contact page to get in touch. Content Copyright © 1997 - 2025 SPI Inc.; See license terms. Debian is a trademark of SPI Inc. Learn more about this site.
🌐
Debian
packages.debian.org › sid › gcc-arm-linux-gnueabi
Debian -- Details of package gcc-arm-linux-gnueabi in sid
This is a dependency package providing the default GNU C cross-compiler for the armel architecture.
🌐
Acmesystems
acmesystems.it › arm9_toolchain
Install the ARM cross compiler toolchain on your Linux PC
Install the GCC, G++ cross compilers ... bc · If you are using an Acqua or RoadRunner board: sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf ·...
🌐
Arch Linux
aur.archlinux.org › packages › arm-linux-gnueabihf-gcc
AUR (en) - arm-linux-gnueabihf-gcc
Install arm-linux-gnueabihf-gcc-stage2 from AUR (with -glibc-headers dependency).
Find elsewhere
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.

🌐
Aw-som
aw-som.com › faq › index.php
Getting started with AW-SoM products - Debian/Ubuntu Install GCC 4.7 ARM Cross Compiler
Lets install a more recent version of the GCC ARM Cross Compiler. ... cd /usr/bin sudo ln -s arm-linux-gnueabihf-gcc-4.7 arm-linux-gnueabihf-gcc sudo ln -s arm-linux-gnueabihf-cpp-4.7 arm-linux-gnueabihf-cpp sudo ln -s arm-linux-gnueabihf-gcc-ar-4.7 arm-linux-gnueabihf-gcc-ar sudo ln -s arm-linux-gnueabihf-gcc-nm-4.7 arm-linux-gnueabihf-gcc-nm sudo ln -s arm-linux-gnueabihf-gcc-ranlib-4.7 arm-linux-gnueabihf-gcc-ranlib sudo ln -s arm-linux-gnueabihf-gcov-4.7 arm-linux-gnueabihf-gcov cd ~/
🌐
Duetorun
duetorun.com › blog › 20230401 › arm-toolchain
Arm GNU Toolchain - ElseWhere
Use the apt command to install software packages on any Debian based Linux distribution. $ sudo apt update $ sudo apt install gcc-arm-none-eabi -y $ sudo apt install gcc-arm-linux-gnueabihf -y $ sudo apt install gcc-aarch64-linux-gnu -y
🌐
Debian
packages.debian.org › bullseye › gcc-arm-linux-gnueabihf
Debian -- Details of package gcc-arm-linux-gnueabihf in bullseye
dep: gcc-10-arm-linux-gnueabihf (>= 10.2.1-3~) GNU C compiler (cross compiler for armhf architecture) rec: libc6-dev-armhf-cross · GNU C Library: Development Libraries and Header Files (for cross-compiling) or libc-dev-armhf-cross · virtual package provided by libc6-dev-armhf-cross ·
🌐
Debian
packages.debian.org › gcc-arm-linux-gnueabihf
Package Search Results -- gcc-arm-linux-gnueabihf
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Debian
packages.debian.org › gcc-12-arm-linux-gnueabihf
Package Search Results -- gcc-12-arm-linux-gnueabihf
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Arm Learning
learn.arm.com › install-guides › gcc › cross
Cross-compiler: Install Guide
sudo apt update sudo apt install gcc-arm-linux-gnueabihf -y sudo apt install gcc-aarch64-linux-gnu -y