odygrd / quill

Asynchronous Low Latency C++ Logging Library
MIT License
1.14k stars 130 forks source link

Linker error with NDK in Release #484

Closed Nathan-M-code closed 3 weeks ago

Nathan-M-code commented 3 weeks ago

Hello, I am trying to use the lib version 4.1.0 with NDK in Release The compilation went fine with this command:

cmake -S .. -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK="$ndkPath" -DCMAKE_INSTALL_PREFIX="$ndkPath/sources/third_party/quill" -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=Release -DQUILL_NO_THREAD_NAME_SUPPORT:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON

I use Quill's format function instead of std one because ndk doesn't support it yet. fmtquill::vformat(translation, fmtquill::make_format_args(args...));

In Debug mode, everything is good and as expected, but in Release mode, I have a linker error

C/C++: ld.lld: error: undefined symbol: fmtquill::v10::vformat(fmtquill::v10::basic_string_view<char>, fmtquill::v10::basic_format_args<fmtquill::v10::basic_format_context<fmtquill::v10::appender, char>>)
C/C++: clang++: error: linker command failed with exit code 1 (use -v to see invocation)
odygrd commented 3 weeks ago

Hey thanks for reporting it, can you try to include format.h from the bundled include folder, in every file you include the logger, and let me know if it works ?

Nathan-M-code commented 3 weeks ago

Yep that works by including #include <quill/bundled/fmt/format.h> ! My bad I should have tested that before reporting the issue. That's the difference between Debug/Release that triggered me. Have a nice day

odygrd commented 3 weeks ago

Since v4 quill is only including core.h from libfmt for the header only version. That is not officially supported but it works under most platforms for primitive types or strings. This is only done to reduce including additional headers.

It seems that for NDK it isn't working, it's something internal to libfmt i do not know why.

I will make format.h for NDK to be always included

odygrd commented 3 weeks ago

this should be fixed in master now with f9d0376d5b8ab06ee89ec5b55e64de9657e0d85b