Unsolved dynamic library based on static qt library?
-
HI,
For gui based app, use QGUIApplication or QApplication, in ur main file.
Thanks,
-
I used QApplication in main file, but the error is caused by the dynamic lib. So does it meas that the Application and the dynamic lib can't share the QApplication instance? Thanks! @Pradeep-Kumar
-
u mean to say while compiling ur lib program, u are getting this errors?.
Thanks,
-
@Pradeep-Kumar said in dynamic library based on static qt library?:
u mean to say while compiling ur lib program, u are getting this errors?.
Thanks,
The error occurs when running the application.
When debugging, the code stops in the dynamic library, the code is create QQmlEngine:
QQmlEngine *s_engine = new QQmlEngine; -
I try to print the value of qApp, in the dynamic lib, it is 0x0,In the main application it has value.
Is this normal? Thanks! @Pradeep-Kumar -
@VVVDEL Looks like the code from your library is executed before QApplication instance was created. Do you have any static variables? Do you execute any code from the library before creating QApplication instance?
-
@jsulm Thanks, and here is the code
main.cpp#include "mainwindow.h" #include <QApplication> #include <testlib.h> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); TestLib testlib; return a.exec(); }
TestLib.cpp
#include "testlib.h" #include <QQmlEngine> TestLib::TestLib() { QQmlEngine *engine = new QQmlEngine; }
-
@VVVDEL Do you have any static variables in your static library?
-
@jsulm No, The above code is the whole code.
-
@VVVDEL How did you build the static lib (same compiler and Qt version?)?
-
@jsulm said in dynamic library based on static qt library?:
@VVVDEL How did you build the static lib (same compiler and Qt version?)?
The Qt version is 5.5.1,and was staticly build under os x 10.10.5
-
@VVVDEL One moment, I thought your lib was static, now I realized that it is shared lib. In this case your shared lib contains Qt stuff AND you app does! (because both used static Qt build)
You should not use static libs this way.
Why do you want to use a static Qt build but still use a shared library? It would be much easier to use shared Qt libs. -
@jsulm The original project was based on static Qt libs. I need to develop some plugins based on the project. Now I know that I need to use dynamic Qt libs.
Thanks you very much.