Хочу добавить в программу логирование с помощью log4cxx. Для начала решил написать пробную программу.
main.cpp
#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
using namespace log4cxx;
using namespace log4cxx::xml;
using namespace log4cxx::helpers;
LoggerPtr loggerMyMain(Logger::getLogger("main"));
int main() {
DOMConfigurator::configure("Log4cxxConfig.xml");
LOG4CXX_FATAL(loggerMyMain, "this is a fatal message!!!");
return 0;
}
pro-файл
QT += core
QT -= gui
TARGET = untitled
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
HEADERS += \
log4cxx/logger.h \
log4cxx/xml/domconfigurator.h
В итоге куча ошибок
debug/main.o: In function `main':
main.cpp:14: undefined reference to `log4cxx::xml::DOMConfigurator::configure(std::string const&)'
main.cpp:15: undefined reference to `log4cxx::Logger::isFatalEnabled() const'
main.cpp:15: undefined reference to `log4cxx::helpers::MessageBuffer::MessageBuffer()'
main.cpp:15: undefined reference to `log4cxx::spi::LocationInfo::LocationInfo(char const*, char const*, int)'
main.cpp:15: undefined reference to `log4cxx::helpers::MessageBuffer::operator<<(char const*)'
main.cpp:15: undefined reference to log4cxx::helpers::MessageBuffer::str(log4cxx::helpers::CharMessageBuffer&)'
main.cpp:15: undefined reference to `log4cxx::Level::getFatal()'
main.cpp:15: undefined reference to log4cxx::Logger::forcedLog(log4cxx::helpers::ObjectPtrT<log4cxx::Level> const&, std::string const&, log4cxx::spi::LocationInfo const&) const'
main.cpp:15: undefined reference to `log4cxx::helpers::MessageBuffer::~MessageBuffer()'
debug/main.o: In function `_static_initialization_and_destruction_0':
main.cpp:9: undefined reference to `log4cxx::Logger::getLogger(char const*)'
debug/main.o: In function `~ObjectPtrT':
log4cxx/helpers/objectptr.h:100: undefined reference to log4cxx::helpers::ObjectPtrBase::~ObjectPtrBase()'
log4cxx/helpers/objectptr.h:100: more undefined references to log4cxx::helpers::ObjectPtrBase::~ObjectPtrBase()' follow
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [debug\untitled.exe] Error 1
mingw32-make.exe: *** [debug] Error 2