Building a shared library with cmake

Folks, this seems very silly, but I cannot seem to build a shared library with cmake, I seem to be able to build the static library, but no matter what I do, the shared library will not be built.

Steps taken (on a Kubuntu 18.04 workstation):

mkdir build_shared && cd build_shared

cmake -BUILD_SHARED_LIBS=yes -DCMAKE_INSTALL_PREFIX=/apps/LAMMPS/22Aug18 …/cmake/

After this is completed, I can run find . | grep *.so which returns nothing.

This seems very silly, but shouldn’t this work? What am I missing. I have read the various web sites and I cannot find what I may be missing.

Thank you for your help.

Silly question: did you remember to CD into the build directories before executing cmake ?

Hi Ethan,

you need to add -D BUILD_LIB=yes in addition to -D BUILD_SHARED_LIBS=yes

cmake -D BUILD_LIB=yes -D BUILD_SHARED_LIBS=yes -D CMAKE_INSTALL_PREFIX=/apps/LAMMPS/22Aug18 …/cmake/

Best,
Richard

Micholas, Thanks for asking the obvious question, but fortunately, I had not forgotten to do that!

Richard, I swear I tried that before and it hadn’t worked. But, I tired again and it did in fact produce the shared library.

Sorry for the noise folks!