CMake / Meson force shared library

Build systems like CMake and Meson have specific syntax and variables to manage shared library creation and linking. By default, CMake builds static libraries, but this can be changed by setting the BUILD_SHARED_LIBS variable to ON or by setting the SHARED type option of the add_library() command.

To use C, C++, Fortran, etc. library binaries from Python, shared libraries are required to load the compiled code at runtime in Python. Of course, the Python code must be configured to match the symbols in the shared library.


Meson builds shared libraries by default, but this can be changed by setting the default_library option to static in project() or by the shared_library() function.