How to set compiler version and C++ version in Makefile.user?

tstucky's picture
Submitted by tstucky on Sat, 05/25/2019 - 00:57

I followed davide1993's instructions for compiling on Mac seen here; manually installing both openmpi and VTK (I'm using 6.3 for compatibility with another software). I am running on MacOS High Sierra.

I get the following compiler error.

mpicxx -funroll-loops -fstrict-aliasing -Wall -Wno-unused-result -O2 -std=c++17 -fPIC -DBOOST_INCLUDED -I/Users/tstucky/usr/local/include/vtk-6.3 -I/opt/local/include -DLAMMPS_VTK -DSUPERQUADRIC_ACTIVE_FLAG -DNONSPHERICAL_ACTIVE_FLAG -c ../compute_pair_gran_local.cpp
In file included from ../compute_pair_gran_local.cpp:50:
In file included from ../pair_gran_proxy.h:58:
In file included from ../granular_pair_style.h:47:
../utils.h:70:12: error: non-const lvalue reference to type 'basic_ostringstream<...>' cannot bind to a temporary of
type 'basic_ostringstream<...>'
return static_cast< std::ostringstream & >(( std::ostringstream() << std::dec << a ) ).str();
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../compute_pair_gran_local.cpp:61:
../fix_multisphere.h:138:13: warning: 'LAMMPS_NS::FixMultisphere::extract' hides overloaded virtual function
void *extract(const char *name, int &len1, int &len2)
../fix.h:241:17: note: hidden overloaded virtual function 'LAMMPS_NS::Fix::extract' declared here: different number of
parameters (2 vs 3)
virtual void *extract(const char *, int &) {return NULL;}
1 warning and 1 error generated.
make[1]: *** [compute_pair_gran_local.o] Error 1
make: *** [auto] Error 2

This thread seems to indicate its because my compiler is using C++17, but I do not see where I can change this in Makefile.user. Editing MPI_CCFLAGS_USR does not replace the existing compiler flags, so even if I put -std=c++98 in that variable I cannot seem to get rid of the -std=c++17 flag. What variable is setting the -std setting?

As for my compiler version: There is no MacPorts version of clang-3.8 available, but I have tried compiling with both clang-3.7 and clang-3.9. Both of them still default to C++11 (or at least that is what the flag is being set to by the previously described unknown variable), and both of them get stuck at the same error.

ahanda | Thu, 10/24/2019 - 21:47

but the file checks for the c++11 or c++17 support at between line 575 and for "Check for c++17 or c++11 support" in your file...There you can set which standard to use...However, your problem will not be fixed by switching to c++11...

replacing the line 70 in file utils.h

from: "return static_cast< std::ostringstream & >(( std::ostringstream() << std::dec << a ) ).str();"
to: "return static_cast< std::ostringstream & >(( std::ostringstream().flush() << std::dec << a ) ).str();"

will fix the error.