Cannot mix incompatible Qt library
-
Hi. Sorry, I know this question has been asked so many times, but I still can't figure out how to solve my problem.
I have two version installed:
-
5.12.3 (w/ mingw73_64)
-
5.15.1 (w/ mingw81_64)
I started working on a project months ago. I built it w/ the first configuration, downloaded a bunch of MYSQL plugin/dll to make it work, and it worked fine.
Now, I would like to move to the second configuration. To do that:
-
I copied the files above in
C\Qt\5.15.1\mingw81_64\plugins\sqldrivers
-
I changed kit
-
I edited my
myProject.pro
to:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/lib/ -llibmysql else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/lib/ -llibmysqld INCLUDEPATH += $$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/include DEPENDPATH += $$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/include
After building and running, the program abruptly crashed during a DB-related operation, with a long message in the output. It follows an excerpt:
loaded library "C:/Qt/5.15.1/mingw81_64/plugins/sqldrivers/qsqlmysql.dll" Cannot mix incompatible Qt library (5.12.3) with this library (5.15.1) 16:45:25: The program has unexpectedly finished.
Could you help me with this?
-
-
As the error message tells you, there are some Qt5.12 dlls in your PATH. Remove them from the PATH and/or fix your kit.
-
@Christian-Ehrlicher
And what should I replace it with? -
@Tamfub As you can see you want 5.15 but 5.12 is somewhere picked up. So make sure 5.12 is no longer picked up - so hard?
-
@Christian-Ehrlicher Ok, but I can't figure out where 5.12 is picked up... I've set 5.15 both in the kit and in the .pro file.
-
Again: take a look in your PATH env var.
-
@Christian-Ehrlicher I've checked my env variables, but no 5.12.3. There was a 5.12.3 before, but I replaced it.
-
@Tamfub said in Cannot mix incompatible Qt library:
I built it w/ the first configuration, downloaded a bunch of MYSQL plugin/dll to make it work, and it worked fine.
...
Now, I would like to move to the second configuration. To do that:
- I copied the files above in
C\Qt\5.15.1\mingw81_64\plugins\sqldrivers
Those DLLs were built with Qt 5.12.3, so you cannot copy them into your Qt 5.15 folder.
You must rebuild those DLLs using Qt 5.15.
- I copied the files above in
-
-
@Tamfub said in Cannot mix incompatible Qt library:
How do I rebuild the DLLs?
See https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows
Should I remove them from my Qt 5.15 folder
Yes, remove everything that you copied. They are incompatible with Qt 5.15.1, as mentioned in your original error message.
add those in the 5.12.3 folder via the "Add libraries..." tool?
No, you cannot add DLLs from Qt 5.12.3 into your Qt 5.15.1 project.
-
@JKSH
I've read what's written here. This is my MySql conf folder:
The files- ./include/mysql.h
- ./bin/libmysql.dll
- /bin/libmysql.lib
are present.
As indicated in the link, I opened a terminal in Windows, in
C:\Qt\5.15.1\Src\qtbase
and typed
qmake -- MYSQL_INCDIR="C:\Program Files (x86)\MySQL\MySQL Server 5.5\include" MYSQL_LIBDIR="C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib"
But I got this:
Instead, this worked:
C:/Qt/5.15.1/mingw81_64/lib
is the value of my PATH env variable, and Qt Creator is running in the background. What am I missing/getting wrong? -
@Tamfub said in Cannot mix incompatible Qt library:
I've read what's written here.
...
The files
- ./include/mysql.h
- ./bin/libmysql.dll
- /bin/libmysql.lib
are present.
...
As indicated in the link, I opened a terminal in Windows, in
C:\Qt\5.15.1\Src\qtbase
and typedqmake -- MYSQL_INCDIR="C:\Program Files (x86)\MySQL\MySQL Server 5.5\include" MYSQL_LIBDIR="C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib"
These are all very good. You are on the right track.
EDIT: You are in the wrong folder. You should be in
qtbase\src\plugins\sqldrivers\
, not inqtbase\
.What am I missing/getting wrong?
Have a closer look at the error message. It says, "ERROR: Cannot run compiler 'g++'.... Maybe you forgot to setup the environment?"
That means your compiler,
g++.exe
, is not found in your terminal's environment.Instead, this worked:
C:/Qt/5.15.1/mingw81_64/lib
is the value of my PATH env variable,This shows that you have successfully added the Qt 5.15.1 DLLs and executables (like
qmake.exe
) to your environment.You must also add your compiler to your environment. When you do that, you should also get a valid output when you type
g++ --version
into your terminal.You can install the MinGW x64 compiler from the Qt online installer. The default folder is
C:\Qt\Tools\mingw810_64\bin
.Qt Creator is running in the background.
Qt Creator has no effect on your terminal's environment. You can close Qt Creator.
-
@JKSH
Hi, I've managed to make my qmake command run
It asked me which edition I would like to use. After that, I got:
If I runmingw32-make
, will it install Qt from scratch and delete my Qt folder? Instead, if I runnmake sub-mysql
, it says that nmake is not recognized. I tried to replace nmake with mingw32-make, but it says
-
Please follow the documentation (and start over with a clean source dir):
C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -version -
@Christian-Ehrlicher is right: You are in the wrong folder. You should be in
qtbase\src\plugins\sqldrivers
You should also clean out your source folders before trying again. (Delete all files that were generated by qmake)
@Tamfub said in Cannot mix incompatible Qt library:
Instead, if I run
nmake sub-mysql
, it says that nmake is not recognized.nmake is for MSVC, not MinGW.
-
@JKSH Ok, got it. Sorry for the silly question, but how do I clean out the source folders? From the terminal with a specific command in a specific folder? From Qt Creator (like this)?
Also, I moved toqtbase\src\plugins\sqldrivers
and re-typed (w/out cleaning)qmake -- MYSQL_INCDIR="C:\Program Files (x86)\MySQL\MySQL Server 5.5\include" MYSQL_LIBDIR="C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib"
, but the usage for qmake appeared in the output. -
@Tamfub said in Cannot mix incompatible Qt library:
how do I clean out the source folders? From the terminal with a specific command in a specific folder? From Qt Creator (like this)?
It depends on how you got your source code.
If you extracted it from a Zip file, the easiest thing to do is delete the source folders and extract it again.
You can't use Qt Creator for this.
the usage for qmake appeared in the output.
It probably means you made a mistake while typing. Check again carefully after you clean your source folder.
I just noticed something else: It looks like you are using 64-bit Qt and 64-bit MinGW. Therefore, you must also use the 64-bit MySQL C connector. (Your screenshots show that you've installed 32-bit MySQL)
-
@JKSH I made it work now, I have mistaken qtbase\src\plugins with qtbase\plugins. Back to my project now. My .pro file contains:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/lib/ -llibmysql else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/lib/ -llibmysqld INCLUDEPATH += $$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/include DEPENDPATH += $$PWD/../../../../../5.15.1/mingw81_64/plugins/sqldrivers/mysql-connector-c-6.1.11-winx64/include
That is:
The kit is:
When I run my project from Qt Creator, it works! I would like to deploy my app, so I go to
[build folder]/release
, clean its content (except the executable), open a terminal and type
windeployqt.exe .
I launch the .exe, but the SQL-related part does not work... This is the output of the windeployqt command:
C:\Qt\Projects\tutorial\progettoMalnati\sharedtexteditor\build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release\release\progettoMalnati_srv_2.exe 64 bit, release executable Adding Qt5Svg for qsvgicon.dll Direct dependencies: Qt5Core Qt5Gui Qt5Network Qt5Sql Qt5Widgets All dependencies : Qt5Core Qt5Gui Qt5Network Qt5Sql Qt5Widgets To be deployed : Qt5Core Qt5Gui Qt5Network Qt5Sql Qt5Svg Qt5Widgets Updating Qt5Core.dll. Updating Qt5Gui.dll. Updating Qt5Network.dll. Updating Qt5Sql.dll. Updating Qt5Svg.dll. Updating Qt5Widgets.dll. Updating libGLESv2.dll. Updating libEGL.dll. Updating D3Dcompiler_47.dll. Updating opengl32sw.dll. Updating libgcc_s_seh-1.dll. Updating libstdc++-6.dll. Updating libwinpthread-1.dll. Creating directory C:/Qt/Projects/tutorial/progettoMalnati/sharedtexteditor/build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release/release/bearer. Updating qgenericbearer.dll. Creating directory C:/Qt/Projects/tutorial/progettoMalnati/sharedtexteditor/build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release/release/iconengines. Updating qsvgicon.dll. Creating directory C:/Qt/Projects/tutorial/progettoMalnati/sharedtexteditor/build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release/release/imageformats. Updating qgif.dll. Updating qicns.dll. Updating qico.dll. Updating qjpeg.dll. Updating qsvg.dll. Updating qtga.dll. Updating qtiff.dll. Updating qwbmp.dll. Updating qwebp.dll. Creating directory C:/Qt/Projects/tutorial/progettoMalnati/sharedtexteditor/build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release/release/platforms. Updating qwindows.dll. Creating directory C:/Qt/Projects/tutorial/progettoMalnati/sharedtexteditor/build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release/release/sqldrivers. Updating qsqlite.dll. Updating qsqlmysql.dll. Updating qsqlodbc.dll. Creating directory C:/Qt/Projects/tutorial/progettoMalnati/sharedtexteditor/build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release/release/styles. Updating qwindowsvistastyle.dll. Creating C:\Qt\Projects\tutorial\progettoMalnati\sharedtexteditor\build-progettoMalnati_srv_2-Desktop_Qt_5_15_1_MinGW_64_bit-Release\release\translations... Creating qt_ar.qm... Creating qt_bg.qm... Creating qt_ca.qm... Creating qt_cs.qm... Creating qt_da.qm... Creating qt_de.qm... Creating qt_en.qm... Creating qt_es.qm... Creating qt_fi.qm... Creating qt_fr.qm... Creating qt_gd.qm... Creating qt_he.qm... Creating qt_hu.qm... Creating qt_it.qm... Creating qt_ja.qm... Creating qt_ko.qm... Creating qt_lv.qm... Creating qt_pl.qm... Creating qt_ru.qm... Creating qt_sk.qm... Creating qt_tr.qm... Creating qt_uk.qm... Creating qt_zh_TW.qm...