Answer the question
In order to leave comments, you need to log in
What's the problem with including nested libraries?
I create in Qt Creator, but I think that the problem is not in it ...
I create a static library lib1 in Qt without using QtCore. The project is obtained, by default, containing the files lib1.cpp and lib1.h,
which describe the empty class Lib1 (only an empty constructor).
I create a test application "Project without Qt", which is called test, I connect this lib to it - everything works.
Now I create the static library lib2 as well as lib1.
lib2.cpp:
#include "lib1.h"
#include "lib2.h"
Lib2::Lib2() {
Lib1 *lib1 = new Lib1();
}
Lib2 *lib2 = new Lib2();
Undefined reference to Lib1::Lib1() in lib2.cpp
Answer the question
In order to leave comments, you need to log in
The order in which libraries are linked is important. If you first link with lib1 and then with lib2, and there are no links to lib1 in test, then what you see will be. It is necessary either to order the libraries so that first those that access external functions go first, and then those that define these functions. Or put all interdependent libraries inside a pair of --start-group --end-group or -( -) directives.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question