- How to install latest stable release of GCC in Linux Mint?
- 4 Answers 4
- How To Install GCC on Linux Mint 20
- Install GCC on Linux Mint 20 Ulyana
- youmych / how-to-install-latest-gcc-on-linux-mint.txt
- How to Install GCC compiler on Linux Mint 20
- Installing GCC compiler on Linux Mint 20
- Getting started with GCC compiler on Linux Mint
- Conclusion
- About the author
- Kamran Sattar Awaisi
How to install latest stable release of GCC in Linux Mint?
I want to install the latest version of GCC (GNU compiler collection) in Linux Mint 17.3. Currently g++ —version returns 4.8.4, whereas the latest stable release is 5.3.
Backporting a more recent version is usually possible, but is also non-trivial. An alternative is a local installation from source. From a cleanliness standpoint, a backport is preferable, though.
Yes, as I said above, a local installation is an option. But you need to be careful that you can cleanly uninstall it afterwards. Building a package is a harder process, but easier and cleaner from a maintenance point of view.
The latest version of Gcc, 9.2, is distributed as source code, if this comment is not deleted by the moderator, then you might find time to read the howto on its original site gcc.gnu.org. Previous answer got deleted for no valid reason IMHO.
4 Answers 4
Your Linux Mint comes pre-installed with a GCC package. So first I would recommend you to check if the package is already present in your system by typing the following command in terminal.
In case you’re not having any such package then use the following command in terminal firstly you’ve add the following repository:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
then use the next command:
sudo apt-get update sudo apt-get install g++-4.7 c++-4.7
There is always basic thing we should learn; take it as prerequisite before linux.. Learn googling. try to do more hard search .
Why would I want to install g++-4.7 , which is a lower version than g++-4.8 , which I already have? I want to upgrade, not downgrade.
it was 4.8 and you need to search before for available latest package with apt-cache search gcc i gave you logic but really you downgraded my points gr8
At present this answer seems incoherent. Please explain why the OP would wish to install v4.7 instead of v5, (preferably without cliches about the virtues of hard work).
download the latest version of gcc
wget http://www.netgull.com/gcc/releases/gcc-5.3.0/gcc-5.3.0.tar.bz2
use command: tar -xjf to unzip the file
Enter the directory that you unzipped just now, say in $HOME/Downloads/gcc-5.3.0 , then type command:
./configure --disable-checking --enable-languages=c,c++,objc --disable-multilib --with-system-zlib prefix=/usr/bin/gcc-5.3
Dependency installation:build GCC requires GMP4.2+, MPFR 2.4.0+, and MPC 0.8.0+ and build essential
sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libc6-dev sudo apt-get install build-essential
Edit if you still get errors message like » zlib.h not found!» you can do the below to fix it:
I am not quiet sure what should be the lastest, because there are always some latest comes out. But you can install any of them in this way.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-8 g++-8 gcc-8 --version
if you want to select gcc-8/g++-8 with higher priority(20 in this case), you also need to
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 20 --slave /usr/bin/g++ g++ /usr/bin/g++-8
Truth be told I’m simply too lazy to move off 17.3 — it works for me. That being said, I still needed a newer gcc. To compile it repeatedly for different targets I have a bash script (see below) that I modify and run (I’m writing my own toy OS, hence I have to use a specially generated gcc).
Change the directories in the script below to match the directories you have. I keep the compiled version in my own directory so I can easily switch between my compiled version and the system’s version. I suggest you do the same. You need to download binutils-2.23.2 as well as the gcc version you are interested in (I’m using 7.1.0 below). Put them into a ~/contrib directory along with the script below.
You might also want to change the line «—enabled-languages=c» to «—enabled-languages=c,c++,objc» — my project only needs C. Another change would be the value of PLATFORM. I use «i686-elf» but that won’t work for you (I changed it below to something that will work for 32-bit platform). You can try «x86_64-linux-gnu» for a 64-bit platform.
For the curious — the reason I build it like this is because the gcc build process used to have a bug that prevented rebuilding in the source directory. I do not know if this bug still exists (I last encountered it in 4.8.0), but the only workaround was to explicitly build in a separate directory if you ever wanted to rebuild.
[EDIT: Perform the installation of the dependencies suggested above by GAD3R]
#!/bin/bash function die() < echo $1 exit 127 >export PREFIX=/home/lelanthran/opt/cross export TARGET=i686-linux-gnu export PATH="$PREFIX/bin:$PATH" pushd $PWD &> /dev/null mkdir -p build-binutils cd build-binutils ../binutils-2.23.2/configure \ --target=$TARGET \ --prefix="$PREFIX" \ --with-sysroot \ --disable-nls \ --disable-werror || die "binutils/config error" make || die "binutils/make error" make install || die "binutils/make install error" popd &> /dev/null pushd $PWD &> /dev/null mkdir -p build-gcc-7.1.0 cd build-gcc-7.1.0 ../gcc-7.1.0/configure \ --target=$TARGET \ --prefix="$PREFIX" \ --disable-nls \ --enable-languages=c \ --without-headers || die "gcc/config error" make all-gcc || die "gcc/make all-gcc error" make all-target-libgcc || die "gcc/make all-target-libgcc error" make install-gcc || die "gcc/make install-gcc error" make install-target-libgcc || die "gcc/make install-target-libgcc error"
How To Install GCC on Linux Mint 20
In this tutorial, we will show you how to install GCC on Linux Mint 20. For those of you who didn’t know, The GNU Compiler Collection (GCC) is a compiler system produced by the GNU project to support various programming languages. The current version is GCC 9.3, released on March 12, 2020, supporting several major programming languages: C, C++, Objective-C, Objective-C++, Fortran, Ada, D, Go, and BRIG (HSAIL).
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘ sudo ‘ to the commands to get root privileges. I will show you through the step-by-step installation of the GNU Compiler Collection (GCC) on a Linux Mint 20 (Ulyana).
Prerequisites
- A server running one of the following operating systems: Linux Mint 20.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A non-root sudo user or access to the root user . We recommend acting as a non-root sudo user , however, as you can harm your system if you’re not careful when acting as the root.
Install GCC on Linux Mint 20 Ulyana
Step 1. Before running the tutorial below, it’s important to make sure your system is up to date by running the following apt commands in the terminal:
Step 2. Installing GCC on Linux Mint 20.
Now we run the following command to install GCC Compiler:
sudo apt install build-essential
Sometimes it’s wise to have a manual page too. Install the manual pages with the following command:
sudo apt install manpages-dev
Verify the GCC compiler installation with the command:
You will see something like below:
gcc (Ubuntu 9.3.5-10ubuntu2) 9.3.5 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Congratulations! You have successfully installed GCC. Thanks for using this tutorial for installing the latest version of GCC Compiler on the Linux Mint system. For additional help or useful information, we recommend you check the official GCC website.
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
youmych / how-to-install-latest-gcc-on-linux-mint.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
These commands are based on a askubuntu answer http://askubuntu.com/a/581497 and https://askubuntu.com/questions/26498/choose-gcc-and-g-version |
To install gcc-7 (gcc-7.2.0), I had to do more stuff as shown below. |
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING. |
ABSOLUTELY NO WARRANTY. |
If you are still reading let’s carry on with the code. |
sudo apt-get update && \ |
sudo apt-get install build-essential software-properties-common -y && \ |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ |
sudo apt-get update && \ |
sudo apt-get install gcc-snapshot -y && \ |
sudo apt-get update && \ |
sudo apt-get install gcc-7 g++-7 gcc-6 g++-6 gcc-multilib -y && \ |
sudo update-alternatives —install /usr/bin/gcc gcc /usr/bin/gcc-7 70 —slave /usr/bin/g++ g++ /usr/bin/g++-7 && \ |
sudo update-alternatives —install /usr/bin/gcc gcc /usr/bin/gcc-6 60 —slave /usr/bin/g++ g++ /usr/bin/g++-6 && \ |
sudo apt-get install gcc-5 g++-5 -y && \ |
sudo update-alternatives —install /usr/bin/gcc gcc /usr/bin/gcc-5 50 —slave /usr/bin/g++ g++ /usr/bin/g++-5; |
When completed, you must change to the gcc you want to work with by default. Type in your terminal: |
sudo update-alternatives —config gcc |
To verify if it worked. Just type in your terminal |
gcc -v |
If everything went fine you should see gcc 7.2.0 by the time I am writing this gist |
Happy coding! |
See blog post at https://www.application2000.com |
How to Install GCC compiler on Linux Mint 20
The GNU compiler collection, which is the abbreviation for GCC, contains multiple compilers for various languages like C, C++, Go, etc. Using GCC, you can easily compile your programs on Linux Mint. Many open-source projects, including Linux Kernel, are compiled using the GCC compiler.
The build-essential package contains the GCC compiler, debugger, and many additional development tools. By installing the build-essential package, we can use GCC compiler on Linux Mint.
Installing GCC compiler on Linux Mint 20
The build-essential package is included in the Linux Mint base repository. open the terminal and update the apt package listing by typing:
Now, install the build-essential package with the command:
To continue installing the build-essential package, type ‘y’ on the command line.
Once the build-essentials package is installed, verify the GCC compiler installation with the command:
Getting started with GCC compiler on Linux Mint
Let’s compile our first C++ program with GCC compiler. Open your text editor and create a hello.cpp file:
printf ( «Hello from LinuxHint \n » ) ;
To compile this C++ program with GCC compiler, write on your terminal
My “hello.cpp” file is compiled successfully, and a new executable file, “a.out,” is created.
Let’s execute the ‘a.out’ file:
You can see that the message is printed on the terminal.
Conclusion
GCC compiler is used to compile the programming files on Linux. This post describes the installation of the GCC compiler on Linux Mint 20.
About the author
Kamran Sattar Awaisi
I am a software engineer and a research scholar. I like to write article and make tutorial on various IT topics including Python, Cloud Computing, Fog Computing and Deep Learning. I love to use Linux based operating systems.