Solved Issues connecting QT to MYSQL
-
You're still mixing up your Qt installations.
QSqlDriverPrivate(QSqlDriver::DbmsType)
was added in 5.15 and replacedQSqlDriverPrivate()
-
@Christian-Ehrlicher So how do I fixed this?
-
Hi,
As @jsulm already wrote: use the full path to the qmake executable from your Qt 5.15 installation.
-
@SGaist So I tried to make a path to the qt qmake, but I have no idea how since I am still new to ubuntu. For what its worth, when I type qmake -version, I get both the linux version 5.12.8 and the qt version 3.1. I tried using chmod but I am getting a permission error. Besides, I am not sure I am doing what you are explaining. Can you please tell me how to do this?
-
In the console, type the full path to where you have the qmake executable.
Something like:
/home/username/Qt/5.15.2/gcc_64/bin/qmake
-
@SGaist So i typed:
/home/luden/Qt/5.15.2/gcc_64/bin/qmake -- MYSQL_PREFIX=/usr/local
and it detected the MySql has a yes. However, when I type make sub-mysql, I get what looks like the same error as above:make sub-mysql
cd mysql/ && ( test -e Makefile || /home/luden/Qt/5.15.2/gcc_64/bin/qmake -o Makefile /home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro ) && make -f Makefile
make[1]: Entering directory '/home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql'
g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -Wno-deprecated-copy -Wno-redundant-move -Wno-format-overflow -Wno-init-list-lifetime -D_REENTRANT -fPIC -DQT_NO_JAVA_STYLE_ITERATORS -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.12.8 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.12.8/QtCore -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -isystem /usr/include/mysql -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp
qsql_mysql.cpp: In constructor ‘QMYSQLDriverPrivate::QMYSQLDriverPrivate()’:
qsql_mysql.cpp:83:42: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’
83 | , tc(QTextCodec::codecForLocale())
| ^
In file included from qsql_mysql.cpp:57:
/usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:66:5: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate()’
66 | QSqlDriverPrivate()
| ^~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:66:5: note: candidate expects 0 arguments, 1 provided
/usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate(const QSqlDriverPrivate&)’
61 | class QSqlDriverPrivate : public QObjectPrivate
| ^~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: no known conversion for argument 1 from ‘QSqlDriver::DbmsType’ to ‘const QSqlDriverPrivate&’
/usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: candidate: ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriverPrivate&&)’
/usr/include/x86_64-linux-gnu/qt5/QtSql/5.12.8/QtSql/private/qsqldriver_p.h:61:7: note: no known conversion for argument 1 from ‘QSqlDriver::DbmsType’ to ‘QSqlDriverPrivate&&’
qsql_mysql.cpp: In member function ‘virtual bool QMYSQLDriver::open(const QString&, const QString&, const QString&, const QString&, int, const QString&)’:
qsql_mysql.cpp:1243:65: error: ‘SkipEmptyParts’ is not a member of ‘Qt’
1243 | const QStringList opts(connOpts.split(QLatin1Char(';'), Qt::SkipEmptyParts));
| ^~~~~~~~~~~~~~make[1]: *** [Makefile:384: .obj/qsql_mysql.o] Error 1
make[1]: Leaving directory '/home/luden/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers/mysql'
make: *** [Makefile:45: sub-mysql] Error 2 -
Cleanup the sources as explained in the documentation and restart the procedure.
-
@SGaist I have tried to uninstall and reinstall the src from the qt maintenance. But I still get the same error. I tried looking up "cleanup sources" on the qt documentation website and got nothing. Do you have the documentation link that explains this procedure?
-
Hi, it's more difficult when you have 2 different versions of Qt installed in the same Ubuntu system, that's why you get this error:
qsql_mysql.cpp:83:42: error: no matching function for call to ‘QSqlDriverPrivate::QSqlDriverPrivate(QSqlDriver::DbmsType)’The 2 different Qt versions are fighting each other (as @Christian-Ehrlicher said above: SqlDriverPrivate(QSqlDriver::DbmsType) was added in 5.15 and replaced QSqlDriverPrivate)
Maybe you could try uninstalling of the 2 Qts...
-
Look at the note under Building The Drivers.
Also, consider using out of source builds, that will makes things simpler to clean on error/retry.
-
@Richard1973 said in Issues connecting QT to MYSQL:
I managed to get qmake working after installing the qt5-default
No, you did not. Instead of simply using absolute path to qmake you installed a different Qt version...
-
So I uninstalled qt5-deafult using sudo apt-remove. When i tried to do the same for the private-dev it just says that it cant find the package. I used maintenance tool to remove everything. For good measures I restarted my computer. I then used run, installed everything for 5.15.2 and for teh developer and creator install the default cmake and ninja.
I then created a new project to connect mysql and qt. Followed the instructions from teh sql-driver. The qmake did not come back with an error and make sub-mysql seems to have worked as well. When I went to reconnect, I still got the same Debug Error as above. But after using make install, everything seems to work now. Even managed to connect and extract information from mysql. So thank you everyone who has helped me.