Search code examples
androidc++nativespdlog

Segmentation fault when logging using spdlog in an app that includes another spdlog


I have a native library that uses spdlog for internal logging.

The library is compiled as shared library and the results .so files are then used in an Android project which has its own JNI and native c++ code which also uses spdlog.

The first time a call to spdlog is made, we experience a SIGSEGV from it. After some research we found that since spdlog is a header-only library it may cause issues when using it this way, so we changed to using it as a static library inside the native library.

This seems to solve the issue but now we get the SIGSEGV on the first call to spdlog from the application's native code.

Are there any limitations or issues with using spdlog this way, specifically in an Android project? Any suggestions on debugging the issue?

If any code can be helpful, let me know what is needed and I'll update the question

Edit

Also, it's worth noting that it only happens when the native library is built in Release mode. In Debug everything works as expected


Solution

  • So turns out the solution was just to upgrade to a newer version of spdlog