error while lammps as a shared lib

Dear Alex:
i get a problem while i am trying to build lammps as a shared lib.
Here is the problem

[100%] Linking CXX executable lmp liblammps.so.0: undefined reference to PyString_FromString' liblammps.so.0: undefined reference to PyCObject_FromVoidPtr’ liblammps.so.0: undefined reference to PyInt_AsLong' liblammps.so.0: undefined reference to PyString_AsString’ liblammps.so.0: undefined reference to `PyInt_FromLong’ collect2: error: ld returned 1 exit status CMakeFiles/lmp.dir/build.make:101: recipe for target ‘lmp’ failed make[2]: *** [lmp] Error 1 CMakeFiles/Makefile2:168: recipe for target ‘CMakeFiles/lmp.dir/all’ failed make[1]: *** [CMakeFiles/lmp.dir/all] Error 2 Makefile:129: recipe for target ‘all’ failed make: *** [all] Error 2

before raise this error, I have done the following steps:

  1. download the latest version of lammps: 7 Aug 2019
  2. mkdir build && cd build
  3. cmake -C …/cmake/presets/minimal.cmake -D BUILD_LIB=on -D BUILD_SHARED_LIBS=on -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV -D PKG_GPU=off -D PYTHON_LIBRARY=/usr/local/lib/libpython3.8.so …/cmake
  4. sudo make -j4 && sudo make install

This problem is out of what i can solve, please tell me how to figure it out; If any information you need that i omitted, i will provide it as soon as possible.
Thanks for your kindly help in advance !

Roy

Why do you set -D PYTHON_LIBRARY?

because at first CMake automatically find my old version libpython3.5.so, and I want it to get new libpython3.8.so. Then I remove it and then CMake detected 2.7.so. So I have to specify manually to this.

获取 Outlook for iOS

But then you also need to provide the matching include directory or else cmake will pick up the wrong one leading to the link error.

Well, I might know what is going wrong. I should also add -D PYTHON_INCLOUD to specify a matching interpreter or else I am using py3 lib but still using py2 interpreter. I will try this, thank you a lot !

获取 Outlook for iOS