2

When i enter following command in the terminal:

gcc --version

It's output something like this:

gcc (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
...

But when i enter below command to see version of the installed gcc package:

apt-cache show gcc | grep Version

I see this:

Version: 4:7.4.0-1ubuntu2.2
Version: 4:7.3.0-3ubuntu2.1
Version: 4:7.3.0-3ubuntu2

Is it normal?

Which version used by software that needs gcc?

mece1390
  • 125
  • 1
  • 10

2 Answers2

2

gcc is installed on your Ubuntu (18.04, 18.10 or 19.04) as well gcc-6 and possibly some other gcc version(s). Although gcc is installed, gcc-6 is currently the default version of gcc. To show all the versions of gcc installed on your OS, run the following command:

apt policy gcc gcc-5 gcc-6 gcc-7 gcc-8 gcc-9     

As you can see from the results of the above command, there are several different alternative versions of gcc in the default Ubuntu repositories, and multiple versions of gcc can be installed alongside each other. You can select which version of gcc to use if multiple versions are installed by following the instructions in How to use multiple instances of gcc?.

karel
  • 114,770
  • Although this probably is right, I don't see how in answers OPs question. – Soren A May 21 '19 at 13:51
  • @SorenA After adding the last sentence, I'm explaining two things. 1. Why there are two different non-matching versions of gcc returned by gcc --version and apt-cache show gcc | grep Version. 2. How to choose which gcc version to use if multiple versions of gcc are installed. – karel May 21 '19 at 13:54
1

/usr/bin/gcc is normally a symbolic link, and it normally points to the default current version of gcc for your system - which in your case appears to be gcc-7.4.0

If the link is pointing to a different version, that's likely because it has been linked manually using ln, or via the update-alternatives system.

Software doesn't "need" gcc at runtime - so it would only affect what version of the compiler is used when you build software from sources.

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • Yes, you'r right. There is no need for runtime purposes. I want to install cuda. As it refered [https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html]here, cuda needs gcc as a prerequisites. – mece1390 May 21 '19 at 17:20