LAMMPS build with coreshell package using C++17

Dear LAMMPS users and developers,

I am trying to build the LAMMPS on Ubuntu with this version: lammps/lammps at stable_29Aug2024_update1. The default of C++ version of this branch is set C++11 in CMakeLists.txt. When I compile it with C++11, the build goes smoothly. However, during test runs with the core-shell interatomic potential, an error message is generated: ERROR: Unrecognized pair style ‘born/coul/wolf/cs’ is part of the CORESHELL package, but seems to be missing because of a dependency (src/force.cpp:275). When using C+11, it generates a lot of the warning saying: warning #4041: constexpr if statements are a C++17 feature. So, I assumed that the coreshell package is not enabled successfully.

When building with C++17 by adding the command set(CMAKE_CXX_STANDARD 17) in cmake/CMakeLists.txt, the build goes very little warnings but fails to create the executable with this error message:
input.cpp:(.text+0x1a35): more undefined references to `__builtin_is_constant_evaluated’ follow
CMakeFiles/lmp.dir/build.make:108: recipe for target ‘lmp’ failed
gmake[2]: *** [lmp] Error 1
CMakeFiles/Makefile2:521: recipe for target ‘CMakeFiles/lmp.dir/all’ failed
gmake[1]: *** [CMakeFiles/lmp.dir/all] Error 2
Makefile:135: recipe for target ‘all’ failed
gmake: *** [all] Error 2

If anyone could provide any guidance on this issue, it would be greatly appreciated.

Here’s the cmake command I am using:

cmake  -D CMAKE_INSTALL_PREFIX=/bin/lammps_cxx17/lammps \
       -D CMAKE_BUILD_TYPE=Release \
       -D BUILD_SHARED_LIBS=off \
       -D LAMMPS_EXCEPTIONS=on \
       -D PKG_USER-INTEL=on \
       -D PKG_MANYBODY=on \
       -D PKG_QEQ=on \
       -D PKG_REAXFF=on \
       -D PKG_MOLECULE=on\
       -D PKG_USER-COLVARS=on \
       -D PKG_KSPACE=on \
       -D PKG_CLASS2=on \
       -D PKG_CORESHELL=on \
       -D PKG_RIGID=on \
       -D MKL_INCLUDE_DIRS=$MKLROOT/include \
       -D MKL_LIBRARIES=$MKLROOT/lib \

My cmake version is 3.20.5.

Best,
Sue

That is not correct. These are two separate issues. The reason that pair style born/coul/wolf/cs is missing is that its implementation is derived from pair style born/coul/wolf and that is part of the EXTRA-PAIR package that you have not enabled. Because of that, the CORESHELL version is skipped over and therefore you get that error.

The constexpr warnings are probably due to enabling MKL from a very recent Intel compiler installation. If I remember correctly the very latest LLVM-based Intel compilers do not support C++11 at all. You seem to be using MKL with a GCC compiler though (what does it say in the summary after running cmake?).

It doesn’t make much sense to use MKL unless you are also using the Intel compilers. Same goes for the INTEL package.

Any error about missing symbols starting with __builtin indicate a problem with inconsistent compiler choices during compilation and linking.

I suggest you try to compile LAMMPS from a clean build folder with the default settings using GCC and -DFFT=kiss and make sure you add -D PKG_EXTRA-PAIR=on to your cmake command line and forget about anything Intel. If that works, you can then incrementally add -D CMAKE_CXX_STANDARD=17, the INTEL package, the Intel compiler, and the MKL library.
Best each from a new and empty build folder and then report back where you get excessive warnings or run failures. Then we can have a closer look.

[Update:]
For your reference, here is my cmake summary from configuring with GCC and without anything Intel for the same LAMMPS sources. There are only a few bogus warnings about some calls to memcpy() that show up for this:

-- <<< Build configuration >>>
   LAMMPS Version:   20240829 stable_29Aug2024_update1
   Operating System: Linux Fedora 41
   CMake Version:    3.30.7
   Build type:       Release
   Install path:     /bin/lammps_cxx17/lammps
   Generator:        Ninja using /usr/bin/ninja-build
-- Enabled packages: CLASS2;CORESHELL;EXTRA-PAIR;KSPACE;MANYBODY;MOLECULE;QEQ;REAXFF;RIGID
-- <<< Compilers and Flags: >>>
-- C++ Compiler:     /usr/lib64/ccache/c++
      Type:          GNU
      Version:       14.2.1
      C++ Standard:  17
      C++ Flags:     -O3 -DNDEBUG
      Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=4;LAMMPS_CURL;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP;LAMMPS_FFMPEG;FFT_KISS
-- <<< Linker flags: >>>
-- Executable name:  lmp
-- Static library flags:    
-- <<< MPI flags >>>
-- MPI_defines:      MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes:     /usr/include/mpich-x86_64
-- MPI libraries:    /usr/lib64/mpich/lib/libmpicxx.so;/usr/lib64/mpich/lib/libmpi.so;
-- <<< FFT settings >>>
-- Primary FFT lib:  KISS
-- Using double precision FFTs
-- Using threaded FFTs
-- Using builtin distributed FFT algorithms
-- Configuring done (1.2s)
-- Generating done (0.0s)

You can easily check if the desired pair style is included with:

$ ./lmp -h | grep born/coul/wolf
born/coul/long  born/coul/long/cs               born/coul/msm   born/coul/wolf  
born/coul/wolf/cs               born/gauss      buck            buck/coul/cut