What version of GCC is used by the make command?

Is there any way to know what version of gcc is used by the make command? I have 5 versions installed of gcc on my computer:
by dpkg -l | grep gcc

ii  gcc                                                   4:4.8.2-1ubuntu6                                    i386         GNU C compiler
ii  gcc-4.6                                               4.6.4-6ubuntu2                                      i386         GNU C compiler
ii  gcc-4.6-base:i386                                     4.6.4-6ubuntu2                                      i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-4.8                                               4.8.2-19ubuntu1                                     i386         GNU C compiler
ii  gcc-4.8-base:i386                                     4.8.2-19ubuntu1                                     i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-4.9-base:i386                                     4.9-20140406-0ubuntu1                               i386         GCC, the GNU Compiler Collection (base package)
ii  libgcc-4.8-dev:i386                                   4.8.2-19ubuntu1                                     i386         GCC support library (development files)
ii  libgcc1:i386                                          1:4.9-20140406-0ubuntu1                             i386         GCC support library

Open the terminal and type:

gcc --version  

If that’s not the version of gcc you want you can change the default gcc version using the update-alternatives command to determine which actual file is referenced by a generic name, for example which actual file is referenced by gcc. For more information see the answers to this question: How to change the default GCC compiler in Ubuntu?.

Answered By: karel

make only does whatever the Makefile tells it to do. Most Makefiles will use the default gcc command, so karel’s answer applies in most cases, but you should be aware that there’s nothing that forces make to use the default GCC. (And for that matter, make can be used for a lot of things besides compiling C, so it might not even use GCC at all.)

Answered By: fkraiem

Makefiles often use implicit rules to compile things, rather than defining the compiler specifically. In this case, the convention (and default) is to use $(CC), which defaults to cc. So if you type cc --version, you’ll see what Makefiles use by default.

The Makefile may override the definition of CC though, or not use $(CC) at all. But is the convention (as it is within autoconf for configure scripts, too).

Also see: https://stackoverflow.com/questions/2969222/make-gnu-make-use-a-different-compiler

Answered By: Robie Basak
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.