Building KIM and Building Lammps with KIM

Hi all,

I build kim-api successfully using the source code. For a quick check I tried " kim-api-collections-management list" but it returns the following error,

/usr/local/bin/…/libexec/kim-api/kim-api-collections-info: error while loading shared libraries: libkim-api.so.2: cannot open shared object file: No such file or directory
Aborting!

I also tried compiling Lammps with the installed kim-apt and the “make-omp” commands returns,

KIM_SimulatorHeaders.h: No such file or directory #include “KIM_SimulatorHeaders.h”

Please find the config of my Linux system bellow,

NAME=“CentOS Linux”
VERSION=“7 (Core)”
ID=“centos”
ID_LIKE=“rhel fedora”
VERSION_ID=“7”

I would appreciate your comment on the issue.

Regards,
Amir Behbahanian

Hi Amir, Thanks for your question.

Did you follow this part of the INSTALL instructions?

The first thing that comes to mind is that the last line sudo ldconfig was accidentally skipped. The second thing, is that you might need to open a new terminal and try the check from there (this would cause a “reload” of the configuration in the new shell).

If neither of these fix things, then we’ll need to investigate further.

Yes, that’s the procedure I followed without the documentation and test part.

OK. Please try to rerun the sudo ldconfig command and use a new shell to see if those will resolve the issue. If not, let me know here.

@relliott Sorry for my bad understanding of your response. I mistakenly read it return instead of the rerun. I have changed the /etc/ld.so.conf file and added lib64 (This was the path mentioned in the \texttt{install.manifest.txt} file) to the paths and now the kim works very well.

But I still have a problem with building \texttt{LAMMPS} with \texttt{KIM} and I get the following error,

In file included from ../style_pair.h:81,
                 from ../force.cpp:21:
../pair_kim.h:70:10: fatal error: KIM_SimulatorHeaders.h: No such file or directory
   70 | #include "KIM_SimulatorHeaders.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:109: force.o] Error 1
make[1]: Leaving directory '/home/u211355/LAMMPS/src/Obj_omp'
make: *** [Makefile:213: omp] Error 2

I appreciate your time and patience.

Best regards,
Amir

Hi Amir, no problems…

Now you’ll need to provide some more details about how you are setting up and compiling LAMMPS. It’s obvious that it can’t find the kim-api header files, but I don’t know why.

I have used the source file to build \texttt{LAMMPS} and already have a working version of \texttt{lmp_omp}. To add \texttt{kim} I first do make yes-kim then do make omp. The error raises after performing the make procedure. my gcc version is (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2) and the following header files are created after make yes-kim.

./kim_command.h
./kim_init.h
./kim_interactions.h
./kim_param.h
./kim_property.h
./kim_query.h
./kim_units.h
./pair_kim.h
./KIM/fix_store_kim.h
./KIM/kim_command.h
./KIM/kim_init.h
./KIM/kim_interactions.h
./KIM/kim_param.h
./KIM/kim_property.h
./KIM/kim_query.h
./KIM/kim_units.h
./KIM/pair_kim.h

Best regards,
Amir

Hi Amir,

There is an additional necessary step when using the “traditional make” system of lammps. You need to follow the instructions here:

https://docs.lammps.org/Build_extras.html#kim

For your case, I think you can do:

make lib-kim args="-p /usr/local"
make yes-kim
make omp

Unfortunately it didn’t solve the problem. is your comment on github related to my problem.

Best regards,
Amir

No, that github issue was related to the lammps cmake build system.

Is /usr/local the right prefix for your install? That is, does (for example) the file /usr/local/include/kim-api/KIM_SimulatorHeaders.h exist on your system?

Also, it may be helpful if you can post the kim-api-configuration-detailed.log file from the kim-api build process.

@relliott the folder contains all the header files, including KIM_SimulatorHeaders.h please find the kim-api-configuration-detailed.log file below;

###
#
#  kim-api configuration:
#
#    === System values ======================
#    CMAKE_SYSEM_NAME:                       Linux
#    CMAKE_SYSTEM_PROCESSOR:                 x86_64
#
#    === C++ compile values =================
#    CMAKE_CXX_COMPILER_ID:                  GNU
#    CMAKE_CXX_COMPILER_VERSION:             9.3.1
#    CMAKE_CXX_COMPILER:
#       /opt/rh/devtoolset-9/root/usr/bin/c++
#    KIM_API_CMAKE_CXX_COMPILER:
#       /opt/rh/devtoolset-9/root/usr/bin/c++
#
#    CMAKE_CXX_STANDARD:                     98
#    CMAKE_CXX_STANDARD_REQUIRED:            ON
#    CMAKE_CXX_EXTENSIONS:                   OFF
#    CMAKE_CXX_FLAGS:                        
#    CMAKE_CXX_FLAGS_DEBUG:                  -g
#    CMAKE_CXX_FLAGS_RELEASE:                -O3 -DNDEBUG
#    CMAKE_CXX_FLAGS_RELWITHDEBINFO:         -O2 -g -DNDEBUG
#    CMAKE_CXX_FLAGS_MINSIZEREL:             -Os -DNDEBUG
#
#    KIM_API_CXX_FLAGS:                      -Wall -Wextra -pedantic
#
#    === C compile values ===================
#    CMAKE_C_COMPILER_ID:                    GNU
#    CMAKE_C_COMPILER_VERSION:               9.3.1
#    CMAKE_C_COMPILER:
#       /opt/rh/devtoolset-9/root/usr/bin/cc
#    KIM_API_CMAKE_C_COMPILER:
#       /opt/rh/devtoolset-9/root/usr/bin/cc
#
#    CMAKE_C_STANDARD:                       90
#    CMAKE_C_STANDARD_REQUIRED:              ON
#    CMAKE_C_EXTENSIONS:                     OFF;C extensions
#    CMAKE_C_FLAGS:                          
#    CMAKE_C_FLAGS_DEBUG:                    -g
#    CMAKE_C_FLAGS_RELEASE:                  -O3 -DNDEBUG
#    CMAKE_C_FLAGS_RELWITHDEBINFO:           -O2 -g -DNDEBUG
#    CMAKE_C_FLAGS_MINSIZEREL:               -Os -DNDEBUG
#
#    KIM_API_C_FLAGS:                        -Wall -Wextra -pedantic
#
#    === Fortran compile values =============
#    CMAKE_Fortran_COMPILER_ID:              GNU
#    CMAKE_Fortran_COMPILER_VERSION:         9.3.1
#    CMAKE_Fortran_COMPILER:
#       /opt/rh/devtoolset-9/root/usr/bin/gfortran
#    KIM_API_CMAKE_Fortran_COMPILER:
#       /opt/rh/devtoolset-9/root/usr/bin/gfortran
#
#    CMAKE_Fortran_FLAGS:                    
#    CMAKE_Fortran_FLAGS_DEBUG:              -g
#    CMAKE_Fortran_FLAGS_RELEASE:            -O3 -DNDEBUG -O3
#    CMAKE_Fortran_FLAGS_RELWITHDEBINFO:     -O2 -g -DNDEBUG
#    CMAKE_Fortran_FLAGS_MINSIZEREL:         -Os -DNDEBUG -Os
#
#    KIM_API_Fortran_FLAGS:                  -std=f2003 -Wall -Wextra -Wimplicit-interface -pedantic
#
#    === Linker values ======================
#    CMAKE_EXE_LINKER_FLAGS:                 
#    CMAKE_EXE_LINKER_FLAGS_DEBUG:           
#    CMAKE_EXE_LINKER_FLAGS_RELEASE:         
#    CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:  
#    CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:      
#
#    KIM_API_EXE_LINKER_FLAGS:               
#
#    === Build type value ===================
#    CMAKE_BUILD_TYPE:                       Release
#
#    === Directory values ===================
#    PROJECT_SOURCE_DIR:
#       /home/u211355/LAMMPS/lib/kim/kim-api-2.2.1
#    PROJECT_BINARY_DIR:
#       /home/u211355/LAMMPS/lib/kim/kim-api-2.2.1/build
#
#    === Install directory values ===========
#    CMAKE_INSTALL_PREFIX:
#       /usr/local
#
#    CMAKE_INSTALL_INCLUDEDIR:               include
#    CMAKE_INSTALL_BINDIR:                   bin
#    CMAKE_INSTALL_LIBDIR:                   lib64
#    CMAKE_INSTALL_LIBEXECDIR:               libexec
#    CMAKE_INSTALL_SYSCONFDIR:               etc
#    CMAKE_INSTALL_DATADIR:                  share
#    CMAKE_INSTALL_DOCDIR:                   share/doc/kim-api
#
#    BASH_COMPLETION_COMPLETIONSDIR:         etc/bash_completion.d
#    ZSH_COMPLETION_COMPLETIONSDIR:          etc/zsh_completion.d
#
#    === kim-api option values ==============
#    KIM_API_PROJECT_NAME:                   kim-api
#    KIM_API_CONFIGURATION_TIMESTAMP:        2021-07-08-14-04-37
#
#    PROJECT_VERSION:                        2.2.1
#    PROJECT_VERSION_STRING:                 2.2.1+GNU.GNU.GNU
#    KIM_API_UID:                            2.2.1+GNU.GNU.GNU.2021-07-08-14-04-37
#
#    KIM_API_LOG_MAXIMUM_LEVEL:              INFORMATION
#
#    KIM_API_BUILD_EXAMPLES:                 ON
#    KIM_API_ENABLE_SANITIZE:                OFF
#    KIM_API_ENABLE_COVERAGE:                OFF
#
#    KIM_API_USER_CONFIGURATION_FILE:
#       .kim-api/2.2.1+GNU.GNU.GNU.2021-07-08-14-04-37/config
#
#    KIM_API_SYSTEM_MODEL_DRIVERS_DIR:
#       ${ORIGIN}/kim-api/model-drivers
#    KIM_API_SYSTEM_PORTABLE_MODELS_DIR:
#       ${ORIGIN}/kim-api/portable-models
#    KIM_API_SYSTEM_SIMULATOR_MODELS_DIR:
#       ${ORIGIN}/kim-api/simulator-models
#
#    KIM_API_USER_MODEL_DRIVERS_DIR_DEFAULT:
#       ~/.kim-api/2.2.1+GNU.GNU.GNU.2021-07-08-14-04-37/model-drivers-dir
#    KIM_API_USER_PORTABLE_MODELS_DIR_DEFAULT:
#       ~/.kim-api/2.2.1+GNU.GNU.GNU.2021-07-08-14-04-37/portable-models-dir
#    KIM_API_USER_SIMULATOR_MODELS_DIR_DEFAULT:
#       ~/.kim-api/2.2.1+GNU.GNU.GNU.2021-07-08-14-04-37/simulator-models-dir
#
###

Thank you so much for your time.

Best regards,
Amir

Can you please provide more output from the make omp command? In particular, what is the compiler command line that leads to the error?

Sure, please find it the following,

OK, something is definitely not right, there should be a -I .... flag for the kim-api on the mpicxx lines. The -I/home/u211355/miniconda3/include looks like it might be a mistake.

Can you list the following files:

../lib/kim/Makefile.lammps
../lib/kim/kim-prefix.txt

@relliott Sure please find it attached.
kim-prefix.txt (10 Bytes)
Makefile.lammps (1.7 KB)

I have also noticed that when I exit the conda base environment I get the following error while doing make omp instead of the previous error, I’m not how it might be related but please find it the following;

Ah-ha, yes the conda env may be causing some issues.

Try this without the conda env.

export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
make lib-kim args="-p /usr/local"
make yes-kim
make omp
1 Like

YES, it solved the problem. Thank you so much.

Best regards,
Amir

Great! Glad I could help.

As an aside, now that we know what’s going on. I think this might have been simpler if the install prefix /usr instead of the default /usr/local is used. I think this is the preference for centos.

@relliott Sorry, I didn’t understand your point. Do you mind expanding more?

centos doesn’t “support” /usr/local by default. So, that is why we needed to add it to the ldconfig file and to set the PKG_CONFIG_PATH environment variable.

If, instead we install the kim-api to the /usr prefix, then I think the regular procedure would work without these additions.

To build the kim-api for installation in the /usr prefix you would do:

cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
make
sudo make install
sudo ldconfig