To build your library with debug-info you should add -g -Og options of the compiler.
If you are using Autotools to build your library then you can add required options to CXXFLAGS and CFLAGS variables when configuring your library:
In case of CMake you can set CMAKE_CXX_FLAGS and CMAKE_C_FLAGS options:
In case of Meson you can set CXXFLAGS and CFLAGS environment variables:
You can check if the library contains the debug-info by this command: