1

In my Makefile I have

CC=g++

When I do mgrep gcc, I have several versions listed like: gnu/gcc/4.2.1 gnu/gcc/4.7.3 etc

I can do a module load to change my gcc version.

Now suppose I want to use multiple versions simultaneously in different makefiles, how do I do it?

Trevor
  • 1,111
  • 2
  • 18
  • 30
user2524261
  • 109
  • 2
  • 10

1 Answers1

1

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:

  1. 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.
  2. Perform module load gnu/gcc/${GCC_VERSION} inside your makefile.
  3. 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]

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227