Fail to compile lammps with electrode package

Hello,

I was trying to build LAMMPS with the ELECTRODE package, using CMake. I am using the lammps-2Aug2023 stable version. The compiler and openmpi I am using is compilers/gnu/4.9.2 and mpi/openmpi/3.0.0/gnu-4.9.2.

My cmake configuration is

cmake -D PKG_ELECTRODE=yes -D PKG_KSPACE=yes -D USE_INTERNAL_LINALG=yes -DBUILD_SHARED_LIBS=on ../cmake

And after that I only make yes-ELECTRODE, yes-KSPACE. When I compiled with “make mpi”, I got the following error,

./liblammps_mpi.a(fix_electrode_conp.o): In function `LAMMPS_NS::FixElectrodeConp::compute_macro_matrices()':
/home/lammps-2Aug2023/src/Obj_mpi/../fix_electrode_conp.cpp:1033: undefined reference to `dgetrf_'
/home/lammps-2Aug2023/src/Obj_mpi/../fix_electrode_conp.cpp:1034: undefined reference to `dgetri_'
./liblammps_mpi.a(fix_electrode_conp.o): In function `LAMMPS_NS::FixElectrodeConp::invert()':
/home/lammps-2Aug2023/src/Obj_mpi/../fix_electrode_conp.cpp:591: undefined reference to `dgetrf_'
/home/lammps-2Aug2023/src/Obj_mpi/../fix_electrode_conp.cpp:592: undefined reference to `dgetri_'
collect2: error: ld returned 1 exit status

I am wondering if anyone have any idea for this?

Cheers,

Catherine

This is a link error, it can’t find the LAPACK library.

Hi, yes I found someone also have this error and fix it with USE_INTERNAL_LINALG=yes this command, but it didn’t work for me. Is it due to the compiler?

It is solved now! Thanks

That setting is for configuring and building with CMake.

You are using the traditional make process and there you need to follow the package library build instructions which are a separate step. Instructions are in the LAMMPS manual at: 3.7. Packages with extra build options — LAMMPS documentation under the “traditional Make” tab.

If you want to include the built in LAPACK/BLAS you also have to build the linalg lib.

If you are struggling with the traditional Make process we strongly recommend to change to CMake based build (in fact, I personally find it extremely difficult to come across a reason for not using the CMake based build process).

Hello Alex, I am exactly using cmake for this, please refer to the first post

These commands are not for using CMake but conventional make and those must not be used at the same time. So you were sending mixed messages.

Regular CMake should find LAPACK and fallback to linalg if it is not found.
Please try one more time from scratch with the latest release (from April 2024) and without forcing linalg. And report the output of the CMake config run.

Here is what I get on my development desktop machine:

$ cmake -S cmake -B build-electrode -C cmake/presets/basic.cmake -D PKG_ELECTRODE=yes
loading initial cache file cmake/presets/basic.cmake
-- The CXX compiler identification is GNU 14.1.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.45.1") 
-- Appending /usr/local/cuda-12.1/lib64 to CMAKE_LIBRARY_PATH: /usr/local/cuda-12.1/lib64
-- Running check for auto-generated files from make-based build system
-- Found MPI_CXX: /usr/lib64/mpich/lib/libmpicxx.so (found version "4.0") 
-- Found MPI: TRUE (found version "4.0")  
-- Looking for C++ include omp.h
-- Looking for C++ include omp.h - found
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5") found components: CXX 
-- The C compiler identification is GNU 14.1.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sgemm_
-- Looking for sgemm_ - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Found BLAS: /usr/lib64/libflexiblas.so  
-- Looking for cheev_
-- Looking for cheev_ - found
-- Found LAPACK: /usr/lib64/libflexiblas.so;-lm;-ldl  
-- Found JPEG: /usr/lib64/libjpeg.so (found version "62") 
-- Found PNG: /usr/lib64/libpng.so (found version "1.6.40") 
-- Found ZLIB: /usr/lib64/libz.so (found version "1.3.0")  
-- Found GZIP: /usr/bin/gzip  
-- Found FFMPEG: /usr/bin/ffmpeg  
-- Found PkgConfig: /usr/bin/pkg-config (found version "2.1.0") 
-- Checking for module 'fftw3'
--   Found fftw3, version 3.3.10
-- Found FFTW3: /usr/lib64/libfftw3.so  
-- Looking for C++ include cmath
-- Looking for C++ include cmath - found
-- Generating style headers...
-- Generating package headers...
-- Generating lmpinstalledpkgs.h...
-- Found Python3: /usr/bin/python3.12 (found version "3.12.3") found components: Interpreter 
-- Found ClangFormat: /usr/bin/clang-format (found suitable version "18.1.6", minimum required is "8.0") 
-- The following tools and libraries have been found and configured:
 * Git
 * MPI
 * OpenMP
 * LAPACK
 * Threads
 * BLAS
 * JPEG
 * PNG
 * ZLIB
 * FFTW3
 * Python3
 * ClangFormat (required version >= 8.0)

-- <<< Build configuration >>>
   LAMMPS Version:   20240417 patch_17Apr2024-184-ge8ee0d9e71
   Operating System: Linux Fedora 40
   CMake Version:    3.28.2
   Build type:       RelWithDebInfo
   Install path:     /home/akohlmey/.local
   Generator:        Unix Makefiles using /usr/bin/gmake
-- Enabled packages: ELECTRODE;KSPACE;MANYBODY;MOLECULE;RIGID
-- <<< Compilers and Flags: >>>
-- C++ Compiler:     /usr/lib64/ccache/c++
      Type:          GNU
      Version:       14.1.1
      C++ Flags:     -O2 -g -DNDEBUG
      Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=4;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP;LAMMPS_FFMPEG;FFT_FFTW3;FFT_FFTW_THREADS
-- C compiler:       /usr/lib64/ccache/cc
      Type:          GNU
      Version:       14.1.1
      C Flags:       -O2 -g -DNDEBUG
-- <<< 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:  FFTW3
-- Using double precision FFTs
-- Using threaded FFTs
-- Using builtin distributed FFT algorithms
-- Configuring done (3.4s)
-- Generating done (0.1s)
-- Build files have been written to: /home/akohlmey/compile/lammps/build-electrode

And it would fall back to linalg, if necessary.

Hi Axel,

Thanks for the points. I rebuild it and the CMake config is as follows,

$ cmake -C ../cmake/presets/basic.cmake -D PKG_ELECTRODE=yes ../cmake/
loading initial cache file ../cmake/presets/basic.cmake
-- The CXX compiler identification is GNU 4.9.2
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/apps/gcc/4.9.2/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/apps/git/2.32.0/gnu-4.9.2/bin/git (found version "2.32.0") 
-- Appending /usr/apps/plumed/2.4.1/gnu-4.9.2/openblas/lib:/usr/apps/lapack/3.8.0/gnu-4.9.2/lib64:/usr/apps/openblas/0.2.14/gnu-4.9.2/lib:/usr/apps/libmatheval/1.1.11/gnu-4.9.2/lib:/usr/apps/numactl/2.0.12/lib:/usr/apps/emacs/28.1/lib:/usr/apps/giflib/5.1.1/gnu-4.9.2/lib:/usr/apps/subversion/1.14.1/lib:/usr/apps/apr-util/1.6.1/lib:/usr/apps/apr/1.7.0/lib:/usr/apps/git/2.32.0/gnu-4.9.2/lib64:/usr/apps/flex/2.5.39/gnu-4.9.2/lib:/usr/apps/gcc/4.9.2/lib:/usr/apps/gcc/4.9.2/lib64 to CMAKE_LIBRARY_PATH: /usr/apps/plumed/2.4.1/gnu-4.9.2/openblas/lib:/usr/apps/lapack/3.8.0/gnu-4.9.2/lib64:/usr/apps/openblas/0.2.14/gnu-4.9.2/lib:/usr/apps/libmatheval/1.1.11/gnu-4.9.2/lib:/usr/apps/numactl/2.0.12/lib:/usr/apps/emacs/28.1/lib:/usr/apps/giflib/5.1.1/gnu-4.9.2/lib:/usr/apps/subversion/1.14.1/lib:/usr/apps/apr-util/1.6.1/lib:/usr/apps/apr/1.7.0/lib:/usr/apps/git/2.32.0/gnu-4.9.2/lib64:/usr/apps/flex/2.5.39/gnu-4.9.2/lib:/usr/apps/gcc/4.9.2/lib:/usr/apps/gcc/4.9.2/lib64
-- Running check for auto-generated files from make-based build system
-- Found MPI_CXX: /usr/apps/openmpi/3.0.0/gnu-4.9.2/lib/libmpi.so (found version "3.1") 
-- Found MPI: TRUE (found version "3.1")  
-- Looking for C++ include omp.h
-- Looking for C++ include omp.h - found
-- Found OpenMP_CXX: -fopenmp (found version "4.0") 
-- Found OpenMP: TRUE (found version "4.0") found components: CXX 
-- The C compiler identification is GNU 4.9.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/apps/gcc/4.9.2/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sgemm_
-- Looking for sgemm_ - not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Found BLAS: /usr/apps/openblas/0.2.14/gnu-4.9.2/lib/libopenblas.so  
-- Looking for cheev_
-- Looking for cheev_ - found
-- Found LAPACK: /usr/apps/openblas/0.2.14/gnu-4.9.2/lib/libopenblas.so;-lpthread;-lm;-ldl  
-- Found JPEG: /usr/lib64/libjpeg.so (found version "62") 
-- Found PNG: /usr/lib64/libpng.so (found version "1.5.13") 
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.7") 
-- Found GZIP: /usr/bin/gzip  
-- Could NOT find FFMPEG (missing: FFMPEG_EXECUTABLE) 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.27.1") 
-- Checking for module 'fftw3'
--   No package 'fftw3' found
-- Looking for C++ include cmath
-- Looking for C++ include cmath - found
-- Generating style headers...
-- Generating package headers...
-- Generating lmpinstalledpkgs.h...
-- Found Python3: /usr/bin/python3.6 (found version "3.6.8") found components: Interpreter 
-- Could NOT find ClangFormat (missing: ClangFormat_EXECUTABLE) (Required is at least version "8.0")
-- The following tools and libraries have been found and configured:
 * Git
 * MPI
 * OpenMP
 * LAPACK
 * Threads
 * BLAS
 * JPEG
 * PNG
 * ZLIB
 * Python3

-- <<< Build configuration >>>
   LAMMPS Version:   20240417 
   Operating System: Linux Red 7.8
   CMake Version:    3.21.1
   Build type:       RelWithDebInfo
   Install path:     /home/c/.local
   Generator:        Unix Makefiles using /usr/bin/gmake
-- Enabled packages: ELECTRODE;KSPACE;MANYBODY;MOLECULE;RIGID
-- <<< Compilers and Flags: >>>
-- C++ Compiler:     /usr/apps/gcc/4.9.2/bin/g++
      Type:          GNU
      Version:       4.9.2
      C++ Flags:     -O2 -g -DNDEBUG
      Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=3;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP;FFT_KISS
-- C compiler:       /usr/apps/gcc/4.9.2/bin/gcc
      Type:          GNU
      Version:       4.9.2
      C Flags:       -O2 -g -DNDEBUG
-- <<< Linker flags: >>>
-- Executable name:  lmp
-- Static library flags:    
-- <<< MPI flags >>>
-- MPI_defines:      MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes:     /lustre/usr/apps/openmpi/3.0.0/gnu-4.9.2/include;/usr/apps/openmpi/3.0.0/gnu-4.9.2/include
-- MPI libraries:    /usr/apps/openmpi/3.0.0/gnu-4.9.2/lib/libmpi.so;
-- <<< FFT settings >>>
-- Primary FFT lib:  KISS
-- Using double precision FFTs
-- Using non-threaded FFTs
-- Using builtin distributed FFT algorithms
-- Configuring done
-- Generating done
-- Build files have been written to: /home/c/Scratch/Tools/lammps-17Apr2024/build

It works good now.

Cheers,

C