The module system is basically just setting up a path to the requested module. If you want a particular compiler in a particular makefile, then you can do three things:
- Expect the user of the makefile to load the correct version before calling Make. Possibly combined with some condition based on
gcc -v|grep ${GCC_VERSION}
to check that it's the right version.
- Perform
module load gnu/gcc/${GCC_VERSION}
inside your makefile.
- Use
CC=/somewhere/path-to-gcc-version/bin/g++
instead of CC=g++
.
Personally, I prefer 1 or 3. You can find out what the path is by doing module load ...
and then which g++
.
[By the way, I would use CXX=g++
and CC=gcc
- assuming you are not compiling files called *.c
as C++-code]