Kea fails to link with log4cplus if the UNICODE macro is defined
This has been observed in the fuzzing experiments on an Ubuntu 20.04 OSS-fuzz container, and also prior to that on my local FreeBSD 13 VM.
When attempting to build Kea, it complains at ./configure
about configure: error: Needs log4cplus library
.
config.log
shows:
conftest.cpp:(.text+0x21): undefined reference to `log4cplus::Logger::getInstance(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
Doing CXXFLAGS='-UUNICODE' LDFLAGS='-UUNICODE' ./configure
fixes it, although it is likely that only one of the set of flags is needed.
What happens is the log4cplus headers have UNICODE macros that makes its code use wide character strings instead of regular strings, hence the undefined symbol. See /usr/include/log4cplus/clogger.h
, /usr/include/log4cplus/tchar.h
, /usr/include/log4cplus/tstring.h
, and others.
log4cplus is likely not the one setting the macro, but likely other dependencies or some system component like the compiler itself. Likely the latter, which is why it appears on fringe systems.
This error could be prevented without manually specifying flags when .configure
-ing. Either:
- Follow in the steps of log4cplus and split the use of its functions according to whether UNICODE is defined or not and provide a
getInstance()
that uses wide character strings if it is defined. - Detect if Kea can link with log4cplus in
configure.ac
and add-UUNICODE
to the set of flags if the error above ocurs. This is rather intrusive and also inaccurate.