Building static object file AND a shared library

Hi all,

(MacOS 10.14.6… yes I know I should update it… )

I want to have a static object file and not mess with setting up the shared library environment on my mac, but I also want to use the shared library in the python interface which seems convenient.

Right now, I make one pass with
“make mode=shared serial” which builds the .so file but gives a lmp_serial object file which requires the .so file.
Then I do a second pass with
“make serial” to generate a lmp_serial which doesn’t require the shared library for simplicity.
Everything works… I can use the static executable without any shared library present, and after I install for python, I can access the LAMMPS module in python. But it seems a bit error prone to need to do the two passes.

What is the preferred build method to generate the shared library AND a static executable with no dependencies? Or do I just always need to run the two passes?


The problem is that you have to know exactly what you are doing to build a static and shared library from the same objects, since you can always build a static library from the objects for a shared library but not necessarily the other way around. The makefiles shipped with LAMMPS are designed so that people make few mistakes. The time to compile is usually negligible in comparison to the time spent running simulations, so there is not much of a loss and disk space is aplenty, too.

Here is a possible workflow for doing both.

  • compile with “make mode=shared serial”
  • install the python module with “make install-python”
  • make a symbolic link “ln -s Obj_shared_serial Obj_serial”
  • delete lmp_serial and liblammps*.so
  • build a static library and executable with “make serial”. That will use the already compiled objects