qcscine / molassembler

Chemoinformatics toolkit with support for inorganic molecules
https://scine.ethz.ch/download/molassembler
BSD 3-Clause "New" or "Revised" License
31 stars 7 forks source link

Linking against shared library #8

Closed awvwgk closed 10 months ago

awvwgk commented 2 years ago

Setting -DBUILD_SHARED_LIBS=ON does only additionally build a shared library and not disable the static library build. Further, linking against the shared library leads to missing symbols for some reason.

Is there a possibility to avoid building the static library and specially link the Python extension module against the shared library (see #6)?

jan-grimo commented 2 years ago

Any static or shared libraries are built from the same set of object files, so nothing gets compiled twice.

The static variant is always built to allow testing of non-public API functions (due to visibility annotations), and is the library variant chosen for the python packages as reasoned here.

See src/CMakeLists.txt:

if(BUILD_SHARED_LIBS)
  # If molassembler is shared, we still need a static variant for linking into
  # the tests and other binaries that hook deeper into molassembler than the
  # public API
  add_library(MolassemblerStatic STATIC [...]

Though avoiding a static library build is not feasible on these grounds, we can add the possibility of linking a shared variant of molassembler into the python module SO if you need.

Feel free to elaborate on your issues with missing symbols, those are clearly not intended behavior.

awvwgk commented 10 months ago

When has this been resolved?