在Qt中使用mingw版本的log4cplus库时出现编译错误如下:
undefined reference to `log4cplus::detail::macro_forced_log(log4cplus::Logger const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int, char const*)'
因为项目依赖了多个库,.pro文件中配置了CONFIG += c++11 c++14,开始以为是c++11和c++14同时出现的问题,经过多次尝试发现该配置无关。
于是新建一个工程,仅仅依赖log4cplus这一个库,编译通过,运行正常。
仔细对比两个工程的.pro文件,发现原工程的.pro文件中有 DEFINES -= UNICODE 的定义,加#注释掉以后编译通过,运行正常。