How does exporting symbols in .so libraries work with CMake?

54 Views Asked by At

this is more of a theoretical question, rather than a problem to solve. I'm having some shared library, ex. library.so

I'm doing

add_library(library SHARED file1.cpp)
target_link_libraries(library PUBLIC somelib)

Then when i have that .so file after building i do: nm -gDC library.so > symbols.txt

symbols.txt contains exported symbols from that .so file, now my question is what cmake code is responsible for exporting symbols to .so libraries?

  • Is it add_library or target_link_libraries that exports the symbols? maybe both?
  • Can i make it, somehow, so that the symbols are not exported from a cpp file or library by setting some kind of keyword?
  • Are there any other cmake functions that can export symbols?
0

There are 0 best solutions below