Compiling parallel version on macOS 10.13

I am compiling FreeFem++ on macOS 10.13 (HighSierra) with all library dependencies from brew. The compiler is gcc-9, the MPI library is openmpi 4.0.2 (from brew again).

I am sticking to the documentation and I am using a very minimalistic configuration:

./configure --enable-download \
–enable-m64 \
–enable-optim \
–with-mpi=mpic++ \
CC=gcc-9 F77=gfortran-9 FC=gfortran-9

(with that mpi compiler wrappers using the same gcc version)

Anyway, when compilation gets to the mpi part, undefined symbols are found and it stops (I post here just the beginning of the error message)

Making all in mpi
depbase=echo parallelempi.o | sed 's|[^/]*$|.deps/&|;s|\.o$||';
/usr/local/bin/mpic++ -DHAVE_CONFIG_H -I. -I…/… -I./…/fflib -I./…/Graphics -I./…/femlib /usr/local/bin/g+±9 -I/usr/local/Cellar/open-mpi/4.0.2/include -I/usr/local/opt/szip/include -I/usr/local/Cellar/hdf5/1.10.5_1/include -I/usr/local/ff-petsc/real/include -DPARALLELE -g -m64 -fPIC -DNDEBUG -O3 -std=c++11 -DBAMG_LONG_LONG -DNCHECKPTR -fPIC -MT parallelempi.o -MD -MP -MF $depbase.Tpo -c -o parallelempi.o parallelempi.cpp &&
mv -f $depbase.Tpo $depbase.Po
config.status: creating ff-mpirun
chmod a+x ff-mpirun
g+±9: warning: /usr/local/bin/g+±9: linker input file unused because linking not done
/usr/local/bin/mpic++ -DPARALLELE -g -m64 -fPIC -DNDEBUG -O3 -std=c++11 -DBAMG_LONG_LONG -DNCHECKPTR -fPIC -o FreeFem+±mpi ffapi.o …/Graphics/sansrgraph.o …/lglib/mymain.o …/lglib/ parallelempi.o …/fflib/libff.a -Wl,-rpath,/usr/local/ff-petsc/real/lib -L/usr/local/ff-petsc/real/lib -lumfpack -lklu -lcholmod -lbtf -lccolamd -lcolamd -lcamd -lamd -lsuitesparseconfig -larpack -llapack -framework Accelerate -L/usr/local/opt/libevent/lib -L/usr/local/Cellar/open-mpi/4.0.2/lib -lmpi -lm -lcblas -L/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9/gcc/x86_64-apple-darwin17/9.2.0 -L/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9/gcc/x86_64-apple-darwin17/9.2.0/…/…/… -lgfortran -lquadmath -lm -L/usr/local/opt/szip/lib -L/usr/local/Cellar/hdf5/1.10.5_1/lib -lm -ldl -lz -lsz -lhdf5 -lhdf5_hl
Undefined symbols for architecture x86_64:
“ShowType(std::basic_ostream<char, std::char_traits >&)”, referenced from:
OneOperator0::E_F0_F::operator basicForEachType const*() const in parallelempi.o
EConstant<fMPI<ompi_op_t*, 4> >::operator basicForEachType const*() const in parallelempi.o
EConstant<fMPI<ompi_communicator_t*, 1>>::operator basicForEachType const() const in parallelempi.o
EConstant::operator basicForEachType const*() const in parallelempi.o
basicForEachType* atype() in parallelempi.o
basicForEachType* atype<void*>() in parallelempi.o
basicForEachType* atype<fMPI<ompi_communicator_t*, 1>*>() in parallelempi.o

Does anybody have a clue on what is going wrong?
Thank you in advance,


P.S. Please ask me if the full output of configure or make can be useful, I cannot attach it as new user.

There is probably some mix up between libc++ and libstdc++. What is your underlying C++ compiler? mpic++ -show will return clang++ I’m guessing.

Sorry, I missed the obvious missing CXX=g++-9 flag. That should fix things.

Solved with this, thanks.
Plus, I had to cleanly set CXX=g++ (with g++ aliasing g++-9 or its path /usr/local/bin/g++-9) without hyphens or slashes to prevent configure from putting the compiler itself in ff_MPI_INCLUDE when parsing the output of mpic++ -show, thus messing up the compilation later on.