Hy People,
I am a very larg project (thesis of my master course) and I would like to take the common stuffs in statical linked library. I have a “main” project: controlPanel and I would like to make a statical linked library project: logging. The logging project use the singleton dessign pattern: a statical instance pointer in the class and it will be initialized in the .cpp file.
logging.h
class Logging {
public: static void init() {
if(logObject == nullptr) {
logObject = new Logging();
logObject->logFile.setFileName(logObject->timeStamp.toString());
logObject->logFile.open(QIODevice::WriteOnly | QIODevice::Text);
logObject->stream.setDevice(&logObject->logFile);
}
}
private: static Logging* logObject;
};
logging.cpp
debugging::Logging* debugging::Logging::logObject = nullptr;
If I call the init method in the main method of controlPanel project, I get the following error at linker time:
/home/moravas/work/sw/thesisOfMSC/controlPanel-build-Desktop_Qt_5_0_1_GCC_64bit-Debug/main.o:-1: In function `debugging::Logging::hardWrite(QString, debugging::logLevel const&)’:
/home/moravas/work/sw/thesisOfMSC/common/logging/logging.h:79: error: undefined reference to `debugging::Logging::logObject’
:-1: error: collect2: error: ld returned 1 exit status
I have tried to set the LIBS variable in th .pro file:
#unix:!macx: LIBS += -lhardFifo
unix:!macx: LIBS += -L$$PWD/../common/hardFifo-build-Desktop_Qt_5_0_1_GCC_64bit-Debug/ -lhardFifo
INCLUDEPATH += $$PWD/../common/hardFifo-build-Desktop_Qt_5_0_1_GCC_64bit-Debug
DEPENDPATH += $$PWD/../common/hardFifo-build-Desktop_Qt_5_0_1_GCC_64bit-Debug
unix:!macx: PRE_TARGETDEPS += $$PWD/../common/hardFifo-build-Desktop_Qt_5_0_1_GCC_64bit-Debug/libhardFifo.a
This is the include of library in my .pro file.
Can somebody help me?
Regards,
Norbert
↧