Unable to compile external project against Lammps C++ library

Hello,
I am currently using the C++ API of Lammps as described here: 1.4.1. Using the C++ API directly — LAMMPS documentation

However since updating from lammps-29Sep2021 to Lammps 2022Sep13, I encounter a compilation error when trying to import “input.h” in my project:

In file included from /home/matthieu/Lammps2022/install/include/lammps/input.h:17,
                 from /home/matthieu/myProject/source/src/Lammps/lammpsController.cpp:24:
/home/matthieu/Lammps2022/install/include/lammps/pointers.h:34:10: fatal error: platform.h: No such file or directory
 #include "platform.h"   // IWYU pragma: export

I limited the Lammps installation to the minimum necessary as follow:

wget https://download.lammps.org/tars/lammps-15Sep2022.tar.gz
tar -xf lammps-15Sep2022.tar.gz
cd lammps-15Sep2022
mkdir -p build
cd build
cmake ../cmake/ -DCMAKE_INSTALL_PREFIX:PATH=/home/matthieu/Lammps2022/install -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
make
make install

Looking at the install folder, the file “platform.h” is not present with the other headers. It is only available in the source folder. Note that this installation method worked fine with lammps-29Sep2021. I didn’t find any updates on how to compile a C++ external driver, so I was wondering if there are additional flags/instructions on how to use the C++ API, or if this might be a regression?

OS: Ubuntu 18.04
gcc 8
cmake version 3.20.0

Thank you for your assistance
Matthieu

The “make install” procedure is somewhat unofficial and not really supported by the (core) LAMMPS developers.

You should instead use the LAMMPS source folder. If you look through the examples in the LAMMPS manual they all are describing that approach.

The only thing that is currently supported with “make install” is the C library interface in the file library.h

Of course, if copying the file to the include folder addresses the compilation failure, then you are free to do so. There will likely be other files needed.

FWIW, I have updated the CMake script code for the “make install” target to include missing headers to be self-contained again so that it should be possible to compile simple programs using the C++ interface. This will become available with the next patch release toward the end of October 2022.

Oh great, thank you very much for the quick update!

Matthieu