Linux gnu gcc version

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

Читайте также:  Compressing data in linux

See Also:

Источник

How to Check GCC Version on a Linux Server ?

There are several reasons why you might need to check the GCC version installed on your Linux system:

  1. Compatibility: Some software packages, libraries, or frameworks require a specific version of GCC to compile or run correctly. By checking the GCC version, you can ensure that your system meets the requirements for building or running the desired software.
  2. Troubleshooting: When facing issues while compiling or building software, checking the GCC version can help you identify whether the problem is related to the compiler version. In some cases, upgrading or downgrading the GCC version might resolve the issue.
  3. Performance improvements: Newer versions of GCC often include optimizations, bug fixes, and performance enhancements. By checking your current GCC version, you can determine if it’s worth upgrading to a more recent version to benefit from these improvements.
  4. Security: Staying up-to-date with the latest GCC version is essential for maintaining the security of your system. Newer versions may contain security patches and fixes for known vulnerabilities. Checking the GCC version helps ensure you are using a secure version of the compiler.
  5. Language features: GCC supports multiple programming languages such as C, C++, Objective-C, Fortran, Ada, D, and others. Newer GCC versions often introduce support for new language features and standards. By checking the GCC version, you can verify if your compiler supports specific language features or standards required for your project.
  6. Collaboration: When working in a team, it’s essential to have a consistent development environment across all team members. Checking the GCC version ensures that all team members are using the same compiler version, which helps avoid issues related to different compiler behaviors or features.
Читайте также:  Linux mplayer нет звука

By checking the GCC version on your Linux system, you can make informed decisions about upgrading, maintaining compatibility, and ensuring the stability and security of your development environment.

To check the version of the GNU Compiler Collection (GCC) installed on your Linux server, follow the steps below:

Step 1: Open a Terminal Window

Open a terminal window on your Linux server or connect to it using an SSH client.

Step 2: Check the GCC Version

In the terminal window, enter the following command to check the GCC version:

This command will display the GCC version installed on your server, along with some additional information. The output should look similar to this:

gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3) Copyright (C) 2010 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.

In this example, the installed GCC version is 4.4.6.

Need extra details?

Using built-in specs. Target: i686-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux Thread model: posix gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)

To find what gcc package was installed, simply run the following command:

[root@centos62 ~]# rpm -qa | grep gcc
libgcc-4.4.6-3.el6.i686 gcc-4.4.6-3.el6.i686

Conclusion

You have successfully checked the GCC version on your Linux server. It’s essential to keep your GCC version up to date, as newer versions often include performance improvements, bug fixes, and new features. If you need to upgrade your GCC version, consult your distribution documentation for specific instructions.

If you have any questions, comments, or suggestions for improvement, please feel free to share your thoughts in the comments section below. Your feedback is invaluable to us, and it helps us create better and more informative content for our users.

Читайте также:  Поднимаем vpn сервер linux

Dimitri Nek

Dimitri is a Linux-wielding geek from Newport Beach and a server optimization guru with over 20 years of experience taming web hosting beasts. Equipped with an arsenal of programming languages and an insatiable thirst for knowledge, Dimitri conquers website challenges and scales hosting mountains with unmatched expertise. His vast knowledge of industry-leading hosting providers allows him to make well-informed recommendations tailored to each client’s unique needs.

Источник

How to know the gcc version used to build the linux?

I use OpenWRT. it’s a linux distribution for embedded systems I want to know the gcc version used to compile the linux I made some researchs in the net but without results. I tried to execute these commands for some existing binary in the linux OpenWRT (like wget)

strings -a | grep "GCC" strings -a | grep "gcc" 
strings -a /lib/libgcc_s.so.1 | grep "gcc" strings -a /lib/libuClibc-0.9.30.1.so | grep "gcc" 

does not give any result Are there a way to know used gcc to build the whole linux (For both user space and kernel space)?

There is no way to determine which gcc is used to build the «whole linux». Each executable may have been built with a different gcc, or even a library within the executable was built with one gcc, or it may not have even been a C program at all (C++, Fortran, Java (with gcj), etc).

2 Answers 2

For programs, it appears in the .comment section of ELF executables, if your system is using ELF.

$ cat main.c int main() < >$ gcc main.c $ objdump -s -j .comment a.out a.out: file format elf64-x86-64 Contents of section .comment: 0000 00474343 3a202844 65626961 6e20342e .GCC: (Debian 4. 0010 372e322d 35292034 2e372e32 00474343 7.2-5) 4.7.2.GCC 0020 3a202844 65626961 6e20342e 342e372d : (Debian 4.4.7- 0030 33292034 2e342e37 00 3) 4.4.7.

The compiler used to compile the kernel is available from the string in /proc/version , for example:

$ cat /proc/version Linux version 3.8.5 (. ) (gcc version 4.7.2 (Debian 4.7.2-5) ) .

A major caveat

The .comment section is optional. Many distributions will strip it from the executable when the executable is bundled into a package. The section will be placed in a separate debug package.

$ objdump -s -j .comment /usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0 /usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0: file format elf64-x86-64 objdump: section '.comment' mentioned in a -j option, but not found in any input file

After installing the libcurl3-dbg package, we get an image with the stripped sections by following the GNU debug link:

$ objdump -s -j .comment \ /usr/lib/debug/.build-id/8c/4ae0ad17a4e76bab47c487047490061bd49de3.debug /usr/lib/debug/.build-id/8c/4ae0ad17a4e76bab47c487047490061bd49de3.debug: file format elf64-x86-64 Contents of section .comment: 0000 4743433a 20284465 6269616e 20342e37 GCC: (Debian 4.7 0010 2e322d35 2920342e 372e3200 .2-5) 4.7.2.

Источник

Оцените статью
Adblock
detector