I have two gcc (same applies to g++) versions installed. The newer one is the default one:
/usr/bin/gcc # 4.9.2
/usr/bin/gcc-4.4 # 4.4.7
For my make command I want to use gcc-4.4 / g++-4.4.
I've tried these three variantes but none seems to work:
export CC="gcc-4.4"
export CPP="g++-4.4"
export CC=/usr/bin/gcc-4.4
export CPP=/usr/bin/g++-4.4
export gcc=/usr/bin/gcc-4.4
export g++=/usr/bin/g++-4.4
The Makefile defines:
# Compiler Options
CC = gcc
CPP = g++
LD = g++
The compiler used by the Makefile is still 4.9.2. How can I use 4.4.7?
You can use make to compile your C and C++ programs by calling gcc or g++ in your makefile to do all the compilation and linking steps, allowing you to do all these steps with one simple command.
I wouldn't say its easy, but you can use the shell function of GNU make to execute a shell command like gcc --version and then use the ifeq conditional expression to check the version number and set your CFLAGS variable appropriately. Save this answer.
Compiler supportGCC has had complete support for C++17 language features since version 8. Clang 5 and later supports all C++17 language features.
GNU Make manual, 6.10 Variables from the Environment:
Variables in
make
can come from the environment in whichmake
is run. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value. However, an explicit assignment in the makefile, or with a command argument, overrides the environment. (If the-e
flag is specified, then values from the environment override assignments in the makefile. But this is not recommended practice.)
The recommended practice is to pass these variables on make
command line:
$ make CC=gcc-4.4 CPP=g++-4.4 CXX=g++-4.4 LD=g++-4.4
A side note is that CXX
is used for compiling C++ code, whereas CPP
is for preprocessing. Either the author of the makefile confused CPP
with CXX
, or the makefile indeed uses CPP
for generating dependencies, which has been unnecessary for the last decade or so. See this for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With