- How to Check the Version of my gcc?
- How to Know the GCC Version Used to Compile Linux kernel on Linux
- Check GCC Compiler Version Used to Compile Kernel
- Install An Older GCC Compiler Version (gcc 4.3.2)
- Check the Version of GCC Compiler Is Installed
- Choose the Default GCC Version
- Checking If GCC Compiler Is Installed On My Linux System
- Checking If GCC Compiler Is Installed
- Installing GNU GCC Compiler
How to Check the Version of my gcc?
Above is the first error in my build log. I didn’t try to compile glibc/gcc myself, and I installed them via yum. One fishy thing I found is:
$ ll /usr/include/c++/ total 4 drwxr-xr-x. 12 root root 4096 Dec 17 14:16 4.8.2 lrwxrwxrwx 1 root root 5 Dec 17 14:16 4.8.5 -> 4.8.2 $
$ yum info gcc-c++ Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.uhost.hk * epel: mirrors.hustunique.com * extras: centos.uhost.hk * updates: centos.uhost.hk Installed Packages Name : gcc-c++ Arch : x86_64 Version : 4.8.5 Release : 4.el7 Size : 16 M Repo : installed From repo : base Summary : C++ support for GCC URL : http://gcc.gnu.org License : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD Description : This package adds C++ support to the GNU Compiler Collection. : It includes support for most of the current C++ specification, : including templates and exception handling.
Any idea how to verify the headers in /usr/include/c++/4.8.2 is indeed from 4.8.5 package? Thanks in advance. P.S. I think probably glibc is irrelevant but here is the info:
$ ldd --version ldd (GNU libc) 2.17 Copyright (C) 2012 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. Written by Roland McGrath and Ulrich Drepper.
How to Know the GCC Version Used to Compile Linux kernel on Linux
If you want to get the running Linux kernel version on your system, you can use the following command to get it.
devops@devops-osetc:~$ uname -a Linux devops-osetc 4.8.0-36-generic #36~16.04.1-Ubuntu SMP Sun Feb 5 09:39:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux devops@devops-osetc:~$ cat /proc/version Linux version 4.8.0-36-generic (buildd@lgw01-18) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #36~16.04.1-Ubuntu SMP Sun Feb 5 09:39:57 UTC 2017
From the above outputs, you can know the current version of running Linux kernel is 4.8.0-36.
Check GCC Compiler Version Used to Compile Kernel
If you installed multiple versions of GCC compilers in your system, and then you want to check the GCC compiler version that used to compile the running Linux kernel on your system, How to achieve the result. You can get it from /proc/version file. type the following command:
Linux version 4.8.0-36-generic (buildd@lgw01-18) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #36~16.04.1-Ubuntu SMP Sun Feb 5 09:39:57 UTC 2017
So we can see from the above outputs that the gcc version is gcc version 5.4.0 .
Install An Older GCC Compiler Version (gcc 4.3.2)
If you need to install an older version of GCC Compiler on your Linux system, you can download the GCC Compiler source package from http://mirrors-usa.go-parts.com/gcc/releases/gcc-4.3.2/gcc-4.3.2.tar.gz, and compile and install the source code. just do the following commands:
$ wget http://mirrors-usa.go-parts.com/gcc/releases/gcc-4.3.2/gcc-4.3.2.tar.gz $ tar -zxvf gcc-4.3.2.tar.gz $ cd gcc-4.3.2 $ ./configure $ make;make install;
Check the Version of GCC Compiler Is Installed
If you want to check the versions of GCC compiler are installed in your Linux system, you can use the following commands:
For Ubuntu/Debian Linux:
devops@devops-osetc:~$ dpkg --list | grep -i gcc ii gcc 4:5.3.1-1ubuntu1 amd64 GNU C compiler ii gcc-3.4 3.4.6-5 amd64 The GNU C compiler ii gcc-3.4-base 3.4.6-5 amd64 The GNU Compiler Collection (base package) ii gcc-5 5.4.0-6ubuntu1~16.04.4 amd64 GNU C compiler ii gcc-5-base:amd64 5.4.0-6ubuntu1~16.04.4 amd64 GCC, the GNU Compiler Collection (base package) ii gcc-6-base:amd64 6.0.1-0ubuntu1 amd64 GCC, the GNU Compiler Collection (base package) ii gir1.2-packagekitglib-1.0 0.8.17-4ubuntu6~gcc5.4ubuntu1.1 amd64 GObject introspection data for the PackageKit GLib library ii libcaca0:amd64 0.99.beta19-2build2~gcc5.2 amd64 colour ASCII art library ii libcc1-0:amd64 5.4.0-6ubuntu1~16.04.4 amd64 GCC cc1 plugin for GDB ii libgcc-5-dev:amd64 5.4.0-6ubuntu1~16.04.4 amd64 GCC support library (development files) ii libgcc1:amd64 1:6.0.1-0ubuntu1 amd64 GCC support library ii libgomp1:amd64 5.4.0-6ubuntu1~16.04.4 amd64 GCC OpenMP (GOMP) support library ii libpackagekit-glib2-16:amd64 0.8.17-4ubuntu6~gcc5.4ubuntu1.1 amd64 Library for accessing PackageKit using GLib ii libquadmath0:amd64 5.4.0-6ubuntu1~16.04.4 amd64 GCC Quad-Precision Math Library ii libunity-action-qt1:amd64 1.1.0+14.04.20140304-0ubuntu2~gcc5.1 amd64 Unity Action Qt API ii libwebrtc-audio-processing-0:amd64 0.1-3ubuntu1~gcc5.1 amd64 AudioProcessing module from the WebRTC project. ii qtchooser 52-gae5eeef-2build1~gcc5.2 amd64 Wrapper to select between Qt development binary versions ii qtdeclarative5-unity-action-plugin:amd64 1.1.0+14.04.20140304-0ubuntu2~gcc5.1 amd64 Unity Action QML Components
For CentOS/RHEL Linux:
$ yum list intalled | grep -i gcc
[root@osetc_test ~]# yum list installed | grep -i gcc gcc.x86_64 4.4.7-23.el6 @base gcc-c++.x86_64 4.4.7-23.el6 @base gcc-gfortran.x86_64 4.4.7-23.el6 @base libgcc.x86_64 4.4.7-23.el6 @base
Choose the Default GCC Version
If you want to compile a C program with a specific version of GCC Compiler, then you need to change the default GCC compiler version, for example, you want to choose the GCC compiler 3.4 as the default compiler. just run one of the following command:
$ sudo rm /usr/bin/gcc $ sudo ln -s /usr/bin/gcc-3.4 /usr/bin/gcc
Verify the default GCC Compiler Version
devops@devops-osetc:~$ gcc --version gcc (GCC) 3.4.6 (Debian 3.4.6-5) Copyright (C) 2006 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.
Video: Check GCC Version Used to Compile running Linux kernel
See Also:
Checking If GCC Compiler Is Installed On My Linux System
This post will guide you how to check if the gcc compiler or g++ compiler are installed on my ubuntu/CentOS/RHEL Linux system. How to check the location of the installed GCC compiler on Linux. HOw to install GNU c/c++ compiler (GCC and G++) on my Linux system.
Checking If GCC Compiler Is Installed
If you want to check if the GNU GCC Compilers are install on your system, you can try to check the version of GCC compiler on Linux, or you can use which command to locate gcc or g++ commands .
Check the Location of GNU or GCC Compiler
Type the following command to check the location of gcc compiler in your system, type:
$ which g++ $ which gcc $which make
devops@devops-osetc:~$ which gcc /usr/bin/gcc devops@devops-osetc:~$ which g++ /usr/bin/g++ devops@devops-osetc:~$ which make /usr/bin/make
Or you can use the type command to achieve the same result of checking the location of all compilers, type:
$ type gcc $ type g++ $ type make
devops@devops-osetc:~$ type gcc gcc is hashed (/usr/bin/gcc) devops@devops-osetc:~$ type g++ g++ is hashed (/usr/bin/g++) devops@devops-osetc:~$ type make make is hashed (/usr/bin/make)
Check Version of Compiler
if you want to check the version of All compilers installed on your Linux system, you just need to execute the following command:
$ gcc --version $ g++ --version $ make --version
devops@devops-osetc:~$ gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 Copyright (C) 2015 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. devops@devops-osetc:~$ g++ --version g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 Copyright (C) 2015 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. devops@devops-osetc:~$ make --version GNU Make 4.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Installing GNU GCC Compiler
For CentOS/RHEL 6/7:
You need to execute the following yum command to install gcc compiler, type:
#yum groupinstall "Developent Tools"
#yum group install "Development Tools"
For Ubuntu/Debian Linux:
you need to run the one of the following command to install compilers, type:
$ sudo apt-get install build-essential
$ sudo apt install build-essential