🌐
Ask Ubuntu
askubuntu.com › questions › 1065484 › installing-gcc-in-ubuntu-18-04-1-on-virtualbox
Installing gcc in Ubuntu 18.04.1 on VirtualBox - Ask Ubuntu
(sudo apt install <package-name>) ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... Stack Gives Back 2025! ... End of Life Notice: Ubuntu 25.04 (Plucky Puffin) reached End of Life on...
🌐
LinuxShout
linux.how2shout.com › home › how to install gcc in ubuntu via terminal or running on virtualbox
How to Install GCC in Ubuntu via Terminal or running on VirtualBox - LinuxShout
February 24, 2025 - Learn how to install GCC on Ubuntu using a terminal running on Virtualbox using this step-by-step guide to learn how to use it
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install gcc compiler on ubuntu
How to Install GCC Compiler on Ubuntu {3 Simple Methods}
February 20, 2025 - This guide showed how to install the GCC compiler on Ubuntu using three different methods.
🌐
YouTube
youtube.com › watch
How to install GCC on Ubuntu - YouTube
Need to install GCC on your Ubuntu system but can’t figure out how to set it up? If so, this guide is for you! Follow along below as we show you how to insta...
Published   April 30, 2021
🌐
Cherry Servers
cherryservers.com › home › blog › linux › how to install gcc on ubuntu 22.04 [and compile a c program]
How to Install GCC on Ubuntu 22.04 [and Compile a C Program] | Cherry Servers
November 7, 2025 - This article will show you how to install GCC on Ubuntu 22.04, compile a C program, and briefly explain the GCC compiler.
🌐
Namehero
namehero.com › blog › how-to-install-gcc-on-ubuntu
How To Install GCC On Ubuntu
November 4, 2024 - You’ll need these to install software and make system changes. If you’re the system administrator or the primary user of your Ubuntu system, you likely already have sudo access. If not, check with your system administrator. Internet Connection: Make sure you have an active internet connection. We’ll be downloading GCC and its dependencies from online repositories.
🌐
DedicatedCore
dedicatedcore.com › home › how to install gcc compiler on ubuntu 22.04
How to Install GCC Compiler on Ubuntu 22.04 - DedicatedCore Blog
January 24, 2025 - The apt package manager is the quickest way to install GCC on Ubuntu. Nevertheless. There are drawbacks to installing GCC from the Ubuntu repositories, including a lack of customization options and potential dependency conflicts.
Find elsewhere
🌐
EVR Mag
evrmag.com › home › how to install gcc in ubuntu via terminal or running on virtualbox
How to Install GCC in Ubuntu via Terminal or running on VirtualBox | EVR Mag
May 1, 2025 - Installing GCC on an Ubuntu system can be done efficiently via the terminal, whether the operating system is installed directly on a machine or running within a VirtualBox virtual environment. Contents Installing GCC on Ubuntu via Terminal Before starting the installation process, it’s a ...
🌐
VirtualBox
forums.virtualbox.org › board index › guest systems › linux guests
Can't install guest additions. - virtualbox.org
This is an Ubuntu question, but what you usually need in a fresh 18.04 installation is: sudo apt-get update sudo apt-get install gcc make perl Are you sure you want the headers? They're installed by default, that's why I'm asking...
Top answer
1 of 4
50

gcc-12 is not available in ubuntu 20.04, so we need to compile it from source code, here are the steps which I borrowed from this video:

  • Step 1: clone gcc source code and checkout gcc-12 branch
$ git clone https://gcc.gnu.org/git/gcc.git gcc-source
$ cd gcc-source/
$ git branch -a
$ git checkout remotes/origin/releases/gcc-12
  • Step 2: make another build dir

Note this is important as running ./configure from within the source directory is not supported as documented here.

$ mkdir ../gcc-12-build
$ cd ../gcc-12-build/
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
  • Step 3: installing GCC prequisites and run configure again

The missing libraries will be shown in above ./confgiure output, search and install them one by one.

$ apt-cache search MPFR
$ sudo apt-get install libmpfrc++-dev
$ apt-cache search MPC | grep dev
$ sudo apt-get install libmpc-dev
$ apt-cache search GMP | grep dev
$ sudo apt-get install libgmp-dev
$ sudo apt-get install gcc-multilib
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++

An alternative is to run the download_prerequisites script.

$ cd ../
$ cd gcc-source/
$ ./contrib/download_prerequisites
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
  • Step 4: compile gcc-12
$ make -j16

Still flex is missing:

$ sudo apt-get install flex
$ ./../gcc-source/configure --prefix=$HOME/install/gcc-12 --enable-languages=c,c++
$ make -j16
$ make install

Another way is to use Ubuntu 22.04 where gcc-12 is available. In Ubuntu 22.04, gcc-12 can be installed with apt:

$ sudo apt install gcc-12
2 of 4
16

You can use Homebrew to install pre-built binaries. Follow instructions to install Homebrew at https://brew.sh/, then

brew install gcc for default GCC (currently 11) or brew install gcc@12 for gcc-12.

Note that it may compile missing dependencies.

🌐
LinuxCapable
linuxcapable.com › home › ubuntu › how to install gcc on ubuntu (26.04, 24.04, 22.04)
How to Install GCC on Ubuntu (26.04, 24.04, 22.04) - LinuxCapable
December 6, 2023 - How to Install VirtualBox on Ubuntu · How to Install Chromium Browser on Ubuntu Linux · Could someone in the know tell me what I am doing wrong with update-alternatives here and how I can do it right, please: %> sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-14 110 –slave /usr/bin/g++ g++ /usr/bin/g++-14 –slave /usr/bin/cpp cpp /usr/bin/cpp-14 –slave /usr/bin/gcov gcov /usr/bin/gcov-14 sudo update-alternatives –config gcc ·
🌐
Linuxize
linuxize.com › home › gcc › how to install gcc compiler on ubuntu 18.04
How to Install GCC Compiler on Ubuntu 18.04 | Linuxize
October 31, 2019 - Te able to add new repositories and install packages on your Ubuntu system, you must be logged in as root or user with sudo privileges . The default Ubuntu repositories contain a meta-package named build-essential that contains the GCC compiler and a lot of libraries and other utilities required for compiling software.
🌐
Columbia University
cs.columbia.edu › ~sedwards › classes › 2015 › 1102-fall › linuxvm.pdf pdf
Setting up C Programming Environment
Install Linux using Virtual Box · 1. Run VirtualBox by double-clicking the icon · 2. Click “New” button on the top left corner · MAC · PC · 3. Click “Continue” on the pop-up window · 4. Type VM name, select “Linux” for the OS and choose · “Ubuntu” for the version.
🌐
Reddit
reddit.com › r/virtualbox › how do i get virtualbox to use gcc 12 instead of gcc 10 rc=-1908
r/virtualbox on Reddit: How do I get VirtualBox to use gcc 12 instead of gcc 10 rc=-1908
December 11, 2022 -

Version no: Version 7.0.2 r154219 (Qt5.15.2)

How do I get VirtualBox to use gcc 12 instead of the default gcc which is 10 on Debian based when starting a virtual machine? I have compiled gcc-12 and is currently sitting in this directory ~/GCC-12.2.0/?

I have installed linux-xanmod, on linux it works fine but on linux-xanmod I get this error message:

The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing

'/sbin/vboxconfig'

I execute this /sbin/vboxconfig and get this output error msg:

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.

So I went into /var/log/vbox-setup.log and I see this:

Building the main VirtualBox module.
Error building the module:
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/6.0.12-x64v1-xanmod1/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j8 modules
make[1]: warning: -j8 forced in submake: resetting jobserver mode.
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc-12 (Debian 12.2.0-9) 12.2.0
  You are using:           gcc (Debian 10.2.1-6) 10.2.1 20210110
make -f ./scripts/Makefile.build obj=/tmp/vbox.0 \
single-build= \
need-builtin=1 need-modorder=1

As it says I need to use gcc-12. So I have already compiled gcc-12 from source and it is in this directory ~/GCC-12.2.0/.

How do I get VirtualBox to use gcc from this directory ~/GCC-12.2.0/ instead of using the default installed gcc-10?

🌐
Oracle VirtualBox
virtualbox.org › wiki › Linux build instructions
Linux build instructions – Oracle VirtualBox
Build in a ​chroot environment or on the target virtual machine to solve this. ... GCC 13 or later GCC 13 is recommended. Linux kernel headers (for the currently booted kernel) ... ia32-libs or lib32z1 (various libraries needed for compiling the 32-bit guest additions, newer versions of Debian/Ubuntu use lib32z1) ... apt-get install --no-install-recommends acpica-tools chrpath doxygen g++-multilib libasound2-dev libcap-dev \ libcurl4-openssl-dev libdevmapper-dev libidl-dev libopus-dev libpam0g-dev \ libpng-dev libpulse-dev qt6-base-dev qt6-scxml-dev qt6-tools-dev qt6-l10n-tools libsdl1.2-dev
🌐
Linuxize
linuxize.com › home › gcc › how to install gcc (build-essential) on ubuntu 20.04
How to Install GCC (build-essential) on Ubuntu 20.04 | Linuxize
June 4, 2020 - To install the Development Tools packages, run the following command as root or user with sudo privileges : ... The command installs a lot of packages, including gcc, g++ and make.
🌐
LinuxConfig
linuxconfig.org › home › how to install gcc the c compiler on ubuntu 20.04 lts focal fossa linux
How to install GCC the C compiler on Ubuntu 20.04 LTS Focal Fossa Linux
September 21, 2025 - Although you can install the C compiler separately by installation of the gcc package, the recommended way to install the C compiler on Ubuntu 20.04 is by installation of the entire development package build-essential. Install C compiler by installation of the development package build-essential: