[lammps-users] Error when build LAMMPS on M1 chip macbook

Dear Axel,

Sorry for previous email.

The version of LAMMPS is 10 Feb 2021, and the OS is MacOs big sur 11.2.1 with M1 chip.

I have tried cmake -C …/cmake/preset/clang.cmake …/cmake and minimal.cmake but all raise an error error:

**LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler.**

Then i try to use traditional make command. I have install mpich3, use which mpicxx echos /usr/local/bin/mpicxx, the mpicxx -v tells


mpicxx for MPICH version 3.4.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
clang: warning: argument unused during compilation: '-I /usr/local/include' [-Wunused-command-line-argument]

but when i type sudo make mac_mpi, it prints

Compiling LAMMPS for machine mac_mpi
/usr/local/bin -O3 -DLAMMPS_GZIP -DLAMMPS_JPEG -DOMPI_SKIP_MPICXX -I/opt/local/include -c …/main.cpp
make[1]: /usr/local/bin: Permission denied
make[1]: *** [main.o] Error 1
make: *** [mac_mpi] Error 2

So i have to send an email to ask how to build LAMMPS on MacOs. I am new to MacOs so I dont know how to modify it.

Thanks in advanced !

Jichen Li
University of Science & Technology of China

Dear Axel,

Sorry for previous email.

The version of LAMMPS is 10 Feb 2021, and the OS is MacOs big sur 11.2.1 with M1 chip.

I have tried cmake -C …/cmake/preset/clang.cmake …/cmake and minimal.cmake but all raise an error error:

**LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler.**

Your cmake installation apparently doesn’t know how to enable C++11 compatibility on your platform. That is not a surprise, since this is a very new platform.
You can try with: cmake -C …/cmake/preset/minimal.cmake -D CMAKE_TUNE_FLAGS=-std=c++11 …/cmake

Then i try to use traditional make command. I have install mpich3, use which mpicxx echos /usr/local/bin/mpicxx, the mpicxx -v tells


mpicxx for MPICH version 3.4.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
clang: warning: argument unused during compilation: '-I /usr/local/include' [-Wunused-command-line-argument]

but when i type sudo make mac_mpi, it prints

NEVER EVER use “sudo” to compile software. that is a very, very, VERY bad idea and can very easily destroy your OS installation.

Compiling LAMMPS for machine mac_mpi
/usr/local/bin -O3 -DLAMMPS_GZIP -DLAMMPS_JPEG -DOMPI_SKIP_MPICXX -I/opt/local/include -c …/main.cpp
make[1]: /usr/local/bin: Permission denied
make[1]: *** [main.o] Error 1
make: *** [mac_mpi] Error 2

for this output to happen, you must have modified the “mac_mpi” makefile in an incorrect way. since you don’t provide that file, it is impossible to recommend any changes.

So i have to send an email to ask how to build LAMMPS on MacOs. I am new to MacOs so I dont know how to modify it.

cmake will work correctly, if you have a cmake version that has been ported to your MacOS platform.
traditional make will work correctly, if you make correct edits.

because your sudo command may have corrupted the state of your build directory, I suggest you remove sources and everything and start over.

I already made a suggestion for how to compile with cmake that should work for your platform. if you want to go with the traditional make procedure instead, I suggest you first copy src/MAKE/Makefile.mpi to src/MAKE/MINE/ and then edit the copy to add -std=c++11 to the CCFLAGS= line near the top. this way, in case there are failures, you can always copy the original over the modified version again and try a different edit. and then try to compile a minimal version with “make mpi”, or similarly do the same with the “serial” makefile in case there is a problem with compiling/linking using your MPI installation. in either case that should get you to a minimal LAMMPS executable and then you can go on to enable the packages you need for your purposes and tune/optimize the specific compilation settings you want.

Axel.

Hi, Axel,

  1. I try the cmake command with cmake -C …/cmake/presets/minimal.cmake -D CMAKE_TUNE_FLAGS=-std=c++11, and configure is done. But when turn to use make, after [100%], the same error occurs again.

In file included from /Users/roy/lammps/src/pointers.h:24:
/Users/roy/lammps/src/lmptype.h:34:2: error: LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler.
#error LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler.

i attach the make summary:


-- <<< Build configuration >>>
Operating System: Darwin
Build type: RelWithDebInfo
Install path: /Users/roy/.local
Generator: Unix Makefiles using /usr/bin/make
-- Enabled packages: KSPACE;MANYBODY;MOLECULE;RIGID
-- <<< Compilers and Flags: >>>
-- C++ Compiler: /Library/Developer/CommandLineTools/usr/bin/c++
Type: AppleClang
Version: 12.0.0.12000032
C++ Flags: -O2 -g -DNDEBUG
Defines: LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP;FFT_KISS
Options: -std=c++11
-- <<< Linker flags: >>>
-- Executable name: lmp
-- Static library flags:
-- <<< MPI flags >>>
-- MPI_defines: MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes: /usr/local/include
-- MPI libraries: /usr/local/lib/libmpicxx.dylib;/usr/local/lib/libmpi.dylib;/usr/local/lib/libpmpi.dylib;
-- <<< FFT settings >>>
-- Primary FFT lib: KISS
-- Using double precision FFTs
-- Using non-threaded FFTs
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/roy/lammps/build

  1. I try make. I copy MACHINES/Makefile.mac_mpi to the MINE, add -std=c++11 to the CCFLAGS. Back to the src and type make:

Gathering installed package information (may take a little while)
Gathering git version information
Compiling LAMMPS for machine mac_mpi
/opt/local/bin/mpicxx-openmpi-mp -O3 -std=c++11 -DLAMMPS_GZIP -DLAMMPS_JPEG -DOMPI_SKIP_MPICXX -I/opt/local/include -c ../main.cpp
make[1]: /opt/local/bin/mpicxx-openmpi-mp: No such file or directory
make[1]: *** [main.o] Error 1
make: *** [mac_mpi] Error 2

Note that my mpich seems not installed at /opt/local/bin/mpicxx-openmpi-mp. So what’s wrong?

Jichen Li
University of Science & Technology of China

On 03/9/2021 20:03,Axel Kohlmeyer[email protected] wrote:

Either your C++ compiler is not conforming to C++ standards or does indeed not (yet) support C++11.
cmake has recognized the flag to turn on C++11 compatibility, but it does not seem to have an effect.
It wouldn’t be the first time that Apple has released incomplete software with a new OS version and hardware.
That is the risk you take when buying from such a vendor.

You did not follow the instructions that I gave you for the traditional make. I told you to copy a different makefile. The one you copied cannot work for obvious reasons.

There is not much else that I can suggest since I don’t have access to a machine running that OS and that kind of hardware.
LAMMPS version 3 March 2020 was the last version that will compile with pre-c++11 compilers.

Axel.