Pgc++: generating dependencies with -MMD flag

Can pgc++ generate dependencies using the -MMD flag in the same step as the generation of the object file? The pgc++ man page doesn’t say one way or the other.

Correct. -MMD, unlike the similar -Mcpp=mmd option, the compiler driver does not halt compilation after preprocessing the file.

1 Like

I’m embarrassed to ask this, since I couldn’t get the -MMD option to work in my Makefile, I attempted to create a separate rule to create the dependencies by invoking only the preprocessor:

%.d : %.cpp
pgc++ (FLAGS) -std=c++11 -Mcpp=mmd < -o $@

This results in the preprocessor errors below, especially that it can’t find the stdexcept include file. Is there a flag that I need in addition to -Mcpp=mmd?

PREPRO-I-0222-Redundant definition for symbol extension (src/HaystackUtil.cpp: -1)
PREPRO-I-0222-Redundant definition for symbol extension (/usr/include/sys/cdefs.h: 358)
PREPRO-F-0206-Can’t find include file stdexcept (src/MpiExceptions.hpp: 5)
PREPRO/x86-64 Linux 19.5-0: compilation aborted

Looks like the driver isn’t adding the system C++ include file directory, so you may need to add these to the compilation.

While this will be system dependent, on my system which has GNU 7.4 installed, I needed to add “-I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7”. You should have similar system directories as well.

I’m using pgc++. Does it have equivalent include directories, or does it use the GNU ones you mention?

In order to be interoperable with g++ objects, pgc++ needs to use the system (GNU) C++ header files.