I create in Qt Creator, but I think that the problem is not in it ...
I create static lib1 library in Qt without using QtCore. The project is obtained, by default, containing the files lib1.cpp and lib1.h, in which the empty class Lib1 is described (only the empty constructor).
I create a test application "Project without Qt", which is called test, connect this lib to it - everything works.
Now I create, like lib1, the static library lib2.
lib2.cpp:
#include "lib1.h" #include "lib2.h" Lib2::Lib2() { Lib1 *lib1 = new Lib1(); } I compile library Lib2 - while everything works as it should.
I insert a line into my application:
Lib2 *lib2 = new Lib2(); And then a strange error appears:
Undefined reference to Lib1 :: Lib1 () in the file lib2.cpp
What a strange mistake? What am I doing wrong?
TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle CONFIG -= qt SOURCES += main.cpp unix:!macx: LIBS += -L$$PWD/../lib1/ -llib1 INCLUDEPATH += $$PWD/../lib1 DEPENDPATH += $$PWD/../lib1 unix:!macx: PRE_TARGETDEPS += $$PWD/../lib1/liblib1.a unix:!macx: LIBS += -L$$PWD/../lib2/ -llib2 INCLUDEPATH += $$PWD/../lib2 DEPENDPATH += $$PWD/../lib2 unix:!macx: PRE_TARGETDEPS += $$PWD/../lib2/liblib2.a
.profiles. - maestro