🌐
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
Discussions

linux - how to install gcc-12 on ubuntu - Stack Overflow
$ sudo apt search gcc-12 Sorting... Done Full Text Search... Done $ uname -a Linux Han 5.10.81.1-microsoft-standard-WSL2 #1 SMP Mon Nov 22 18:52:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux I am usi... More on stackoverflow.com
🌐 stackoverflow.com
virtualbox - How to install gcc make perl package in virtual box with rhel 7.5 os - Stack Overflow
I couldn't install guest addition on virtual box version 5.2.12 error caused- This system is currently not set up to build kernel modules. Please install the gcc make perl packages from your distri... More on stackoverflow.com
🌐 stackoverflow.com
How do I get VirtualBox to use gcc 12 instead of gcc 10 rc=-1908
This is just a friendly reminder in case you missed it. Your post must include: The version of VirtualBox you are using The host and guest OSes Whether you have enabled VT-x/AMD-V (applicable to all hosts running 6.1 and above) and disabled HyperV (applicable to Windows 10 Hosts) Whether you have installed Guest Additions and/or Host Extensions (this solves 90% of the problems we see) PLUS a detailed description of the problem, what research you have done, and the steps you have taken to fix it. Please check Google and the VirtualBox Manual before asking simple questions. Please also check our FAQ and if you find your question is answered there, PLEASE remove your post or at least change the flair to Solved. If this is your first time creating a virtual machine, we have a guide on our wiki that covers the important steps. Please read it here. If you have met these requirements, you can ignore this comment. Your post has not been deleted -- do not re-submit it. Thanks for taking the time to help us help you! Also, PLEASE remember to change the flair of your post to Solved after you have been helped! I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/virtualbox
9
2
December 11, 2022
Ubuntu 24.04 and VirtualBox
Just tried on 7.0.18, now is fixed More on reddit.com
🌐 r/Ubuntu
8
6
April 27, 2024
🌐
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.
🌐
LinuxCapable
linuxcapable.com › home › ubuntu › how to install gcc on ubuntu 26.04, 24.04 and 22.04
How to Install GCC on Ubuntu 26.04, 24.04 and 22.04 - LinuxCapable
1 week ago - How to Install VirtualBox on Ubuntu 26.04, 24.04 and 22.04 · How to Install Chromium Browser on Ubuntu 26.04, 24.04 and 22.04 · 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
🌐
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 ...
🌐
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
🌐
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.
Find elsewhere
🌐
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.
🌐
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.
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.

🌐
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.
🌐
VirtualBox
forums.virtualbox.org › board index › guest systems › linux guests
Can't install guest additions. - virtualbox.org
March 22, 2019 - 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...
🌐
NAKIVO
nakivo.com › linux › how to install ubuntu on virtualbox: detailed overview
How to Install Ubuntu on VirtualBox as a VM: Complete Walkthrough
April 3, 2026 - sudo apt-get install build-essential gcc make perl dkms · You may need to type admin credentials when using sudo. ... After restarting the VM, open Linux terminal and go to the directory of the virtual CD with Guest Additions.
🌐
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.
🌐
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?

🌐
LinuxConfig
linuxconfig.org › home › how to install gcc the c compiler on ubuntu 18.04 bionic beaver linux
How to install GCC the C compiler on Ubuntu 18.04 Bionic Beaver Linux
September 22, 2025 - Learn how to install GCC on Ubuntu. Follow step-by-step instructions to set up your C compiler and verify your installation easily.