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
[-Woverloaded-virtual]
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 Makefile.auto file checks for the c++11 or c++17 support at between line 575 and 592...search for "Check for c++17 or c++11 support" in your Makefile.auto 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.

liammo29 | Tue, 04/27/2021 - 05:45

I replaced the line 70 which removed that error, but still have several errors about c++17. How do I actually switch this to c++11?
Errors are:
In file included from ../rolling_model_luding.h:48:
../math_vector.h:97:3: error: ISO C++17 does not allow 'register' storage class
specifier [-Wregister]
register double f = sqrt(vec_dot(dest, dest));
^~~~~~~~~
../math_vector.h:225:3: error: ISO C++17 does not allow 'register' storage class
specifier [-Wregister]
register double det = form_det(m);
^~~~~~~~~
../math_vector.h:380:3: error: ISO C++17 does not allow 'register' storage class
specifier [-Wregister]
register double f = m[6]*m[7]-m[5]*m[8];
^~~~~~~~~
../math_vector.h:390:3: error: ISO C++17 does not allow 'register' storage class
specifier [-Wregister]
register double det = form4_det(m);
^~~~~~~~~
In file included from ../contact_models.cpp:72:
In file included from ../contact_models.h:69:
In file included from ../style_cohesion_model.h:2:
../cohesion_model_easo_capillary_viscous.h:328:20: warning: unused variable 'v'
[-Wunused-variable]
double **v = atom->v;
^
In file included from ../contact_models.cpp:72:
In file included from ../contact_models.h:69:
In file included from ../style_cohesion_model.h:5:
../cohesion_model_washino_capillary_viscous.h:567:31: warning: private field
'mm_liquid_transfer' is not used [-Wunused-private-field]
MeshModuleLiquidTransfer *mm_liquid_transfer;
^
2 warnings and 4 errors generated.