[lammps-users] Compile LAMMPS as a shared library and enable exceptions and PNG support

Hi,

I am using the LAMMPS version of 29Sep21 on my mac and trying to compile it as a shared library and enable expectation and PNG support. I used the command below:

make serial mode=shlib LMP_INC="-DLAMMPS_PNG -DLAMMPS_EXCEPTIONS" JPG_LIB="-lpng", 

It says:

"

four comments:

  1. changing makefile settings from the command line is not recommended. there is no record of what you did and whether they are consistent.
    the recommended way to make changes is to copy src/MAKE/Makefile.serial to src/MAKE/MINE/Makefile.serial and then edit the latter file according to the comments in the file and the information given for the traditional make procedure in the documentation: https://docs.lammps.org/Build_settings.html

  2. when making changes to the makefile (even if you go against my recommendation and do it only from the command line), you must first do a “make mode=shlib clean-serial” and then recompile all object files again.
    this may lead to compilation errors already during the compilation based on what your current error is

  3. your PNG library is not in a default location, so you need to also provide the location of that folder with the -L flag. that usually means that also the include folder is in a different folder and compilation may fail until also a suitable -I flag is provided (that is a capital “i”).

  4. considering your struggles with (rather basic) settings for a conventional makefile (and thus your apparent lack of experience) you would make your life significantly easier using the CMake build procedure.
    there you will get errors much earlier and CMake can auto-detect most settings, if the supporting information is located where it can find it.