Re-setting `COMPILE.cpp` and `LINK.cpp` makefile variables

I would like to ask where makefile variables COMPILE.cpp and LINK.cpp are defined? I would like to modify them. I tried to find them in the source files of Stan and CmdStan with grep, but I was unsuccessful. Please let me know, what would be an elegant way to re-set these variables.

I don’t believe that those are Stan makefile variables, what are you trying to change?

@andrjohns is correct, those are built in to Make (see their docs for a less-than-perfect explanation).

Generally speaking, COMPILE.cpp is equivalent to $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c, so you should instead set the value of CXX or one of the other variables

1 Like

I’m trying to re-set COMPILE.cpp and LINK.cpp commands to use mpic++.

To view the definitions of COMPILE.cpp and LINK.cpp launch make -p in a directory that has no makefile.

Below are the standard definitions:


I spelled them out in the make/program and replaced CXX with MPICXX. In my case MPICXX = mpic++.

I think the slightly more typical thing to do would just be to set CXX = MPICXX, rather than re-define the COMPILE and LINK, but I’m glad you have it working!

1 Like