Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QT 5.14 build with MySQL Connector C 6.1 Error



  • Sorry about my English, but I met some error need to fix it.

    I have built MySQL successfully with MySQL8.0 x64 with below step

    1. run Qt 5.14.1 (MinGW 7.3.0 64-bit)
    2. cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers
    3. qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Server 8.0/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Server 8.0/lib"
    4. make sure "MySql .................................. yes"
    5. mingw32-make
    6. mingw32-make install
    

    Then I used similar step to build MySQL Connector C 6.1 x86, like

    1. run  Qt 5.14.1 (MinGW 7.3.0 32-bit)
    2. cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers
    3. qmake -- MYSQL_INCDIR="C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files (x86)/MySQL/MySQL Connector C 6.1/lib"
    4. make sure "MySql .................................. yes"
    5. mingw32-make
    

    And I got lots of "undefined reference" from "qsql_mysql.cpp", How should I do? Thanks!

    ...
    ...
    ...
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: undefined reference to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: more undefined references to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE' follow
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:239: undefined reference to `_imp___ZN10QArrayData10deallocateEPS_jj'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: undefined reference to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: undefined reference to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: undefined reference to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: undefined reference to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: undefined reference to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:225: more undefined references to `_imp___ZN10QArrayData8allocateEjjj6QFlagsINS_16AllocationOptionEE' follow
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:239: undefined reference to `_imp___ZN10QArrayData10deallocateEPS_jj'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/Tools/mingw730_32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/bits/atomic_base.h:396: undefined reference to `_imp___ZN10QArrayData11shared_nullE'
    .obj/qsql_mysql.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qarraydata.h:239: undefined reference to `_imp___ZN10QArrayData10deallocateEPS_jj'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV19QMYSQLResultPrivate[__ZTV19QMYSQLResultPrivate]+0x10): undefined reference to `QSqlResultPrivate::fieldSerial(int) const'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x14): undefined reference to `QSqlResult::setAt(int)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x18): undefined reference to `QSqlResult::setActive(bool)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x1c): undefined reference to `QSqlResult::setLastError(QSqlError const&)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x20): undefined reference to `QSqlResult::setQuery(QString const&)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x24): undefined reference to `QSqlResult::setSelect(bool)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x28): undefined reference to `QSqlResult::setForwardOnly(bool)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x34): undefined reference to `QSqlResult::savePrepare(QString const&)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x38): undefined reference to `QSqlResult::bindValue(int, QVariant const&, QFlags<QSql::ParamTypeFlag>)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x3c): undefined reference to `QSqlResult::bindValue(QString const&, QVariant const&, QFlags<QSql::ParamTypeFlag>)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x54): undefined reference to `QSqlResult::fetchPrevious()'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x74): undefined reference to `QSqlResult::execBatch(bool)'
    .obj/qsql_mysql.o:qsql_mysql.cpp:(.rdata$_ZTV12QMYSQLResult[__ZTV12QMYSQLResult]+0x7c): undefined reference to `QSqlResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy)'
    .obj/main.o: In function `ZN18QMYSQLDriverPlugin6createERK7QString':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/main.cpp:64: undefined reference to `_imp___ZNK7QStringeqE13QLatin1String'
    .obj/main.o: In function `ZNK18QMYSQLDriverPlugin10metaObjectEv':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/main.moc:78: undefined reference to `_imp___ZNK11QObjectData17dynamicMetaObjectEv'
    .obj/main.o: In function `ZN18QMYSQLDriverPluginC2Ev':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/main.cpp:58: undefined reference to `_imp___ZN16QSqlDriverPluginC2EP7QObject'
    .obj/main.o:C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/main.cpp:58: undefined reference to `_imp___ZN16QSqlDriverPluginC2EP7QObject'
    .obj/main.o:C:/Qt/Qt5.14.1/5.14.1/mingw73_64/include/QtCore/qsharedpointer_impl.h:682: undefined reference to `_imp___ZN15QtSharedPointer20ExternalRefCountData9getAndRefEPK7QObject'
    .obj/main.o: In function `ZN18QMYSQLDriverPlugin11qt_metacastEPKc':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/main.moc:86: undefined reference to `_imp___ZN16QSqlDriverPlugin11qt_metacastEPKc'
    .obj/main.o: In function `ZN18QMYSQLDriverPlugin11qt_metacallEN11QMetaObject4CallEiPPv':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/main.moc:91: undefined reference to `_imp___ZN16QSqlDriverPlugin11qt_metacallEN11QMetaObject4CallEiPPv'
    .obj/main.o: In function `ZN18QMYSQLDriverPluginD1Ev':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/main.cpp:46: undefined reference to `_imp___ZN16QSqlDriverPluginD2Ev'
    .obj/main.o:C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/main.cpp:46: undefined reference to `_imp___ZN16QSqlDriverPluginD2Ev'
    .obj/main.o: In function `_static_initialization_and_destruction_0':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/main.moc:73: undefined reference to `_imp___ZN16QSqlDriverPlugin16staticMetaObjectE'
    .obj/main.o:main.cpp:(.rdata$_ZTV18QMYSQLDriverPlugin[__ZTV18QMYSQLDriverPlugin]+0x1c): undefined reference to `QObject::event(QEvent*)'
    .obj/main.o:main.cpp:(.rdata$_ZTV18QMYSQLDriverPlugin[__ZTV18QMYSQLDriverPlugin]+0x20): undefined reference to `QObject::eventFilter(QObject*, QEvent*)'
    .obj/main.o:main.cpp:(.rdata$_ZTV18QMYSQLDriverPlugin[__ZTV18QMYSQLDriverPlugin]+0x24): undefined reference to `QObject::timerEvent(QTimerEvent*)'
    .obj/main.o:main.cpp:(.rdata$_ZTV18QMYSQLDriverPlugin[__ZTV18QMYSQLDriverPlugin]+0x28): undefined reference to `QObject::childEvent(QChildEvent*)'
    .obj/main.o:main.cpp:(.rdata$_ZTV18QMYSQLDriverPlugin[__ZTV18QMYSQLDriverPlugin]+0x2c): undefined reference to `QObject::customEvent(QEvent*)'
    .obj/main.o:main.cpp:(.rdata$_ZTV18QMYSQLDriverPlugin[__ZTV18QMYSQLDriverPlugin]+0x30): undefined reference to `QObject::connectNotify(QMetaMethod const&)'
    .obj/main.o:main.cpp:(.rdata$_ZTV18QMYSQLDriverPlugin[__ZTV18QMYSQLDriverPlugin]+0x34): undefined reference to `QObject::disconnectNotify(QMetaMethod const&)'
    .obj/moc_qsql_mysql_p.o: In function `ZNK12QMYSQLDriver10metaObjectEv':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/moc_qsql_mysql_p.cpp:78: undefined reference to `_imp___ZNK11QObjectData17dynamicMetaObjectEv'
    .obj/moc_qsql_mysql_p.o: In function `ZN12QMYSQLDriver11qt_metacastEPKc':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/moc_qsql_mysql_p.cpp:86: undefined reference to `_imp___ZN10QSqlDriver11qt_metacastEPKc'
    .obj/moc_qsql_mysql_p.o: In function `ZN12QMYSQLDriver11qt_metacallEN11QMetaObject4CallEiPPv':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/moc_qsql_mysql_p.cpp:91: undefined reference to `_imp___ZN10QSqlDriver11qt_metacallEN11QMetaObject4CallEiPPv'
    .obj/moc_qsql_mysql_p.o: In function `_static_initialization_and_destruction_0':
    C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql/.moc/moc_qsql_mysql_p.cpp:73: undefined reference to `_imp___ZN10QSqlDriver16staticMetaObjectE'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x1c): undefined reference to `QObject::event(QEvent*)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x20): undefined reference to `QObject::eventFilter(QObject*, QEvent*)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x24): undefined reference to `QObject::timerEvent(QTimerEvent*)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x28): undefined reference to `QObject::childEvent(QChildEvent*)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x2c): undefined reference to `QObject::customEvent(QEvent*)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x30): undefined reference to `QObject::connectNotify(QMetaMethod const&)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x34): undefined reference to `QObject::disconnectNotify(QMetaMethod const&)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x38): undefined reference to `QSqlDriver::isOpen() const'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x5c): undefined reference to `QSqlDriver::sqlStatement(QSqlDriver::StatementType, QString const&, QSqlRecord const&, bool) const'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x74): undefined reference to `QSqlDriver::subscribeToNotification(QString const&)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x78): undefined reference to `QSqlDriver::unsubscribeFromNotification(QString const&)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x7c): undefined reference to `QSqlDriver::subscribedToNotifications() const'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x84): undefined reference to `QSqlDriver::stripDelimiters(QString const&, QSqlDriver::IdentifierType) const'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x88): undefined reference to `QSqlDriver::cancelQuery()'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x8c): undefined reference to `QSqlDriver::setOpen(bool)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x90): undefined reference to `QSqlDriver::setOpenError(bool)'
    .obj/moc_qsql_mysql_p.o:moc_qsql_mysql_p.cpp:(.rdata$_ZTV12QMYSQLDriver[__ZTV12QMYSQLDriver]+0x94): undefined reference to `QSqlDriver::setLastError(QSqlError const&)'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make[1]: *** [Makefile:73: ../plugins/sqldrivers/qsqlmysql.dll] Error 1
    mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.14.1/5.14.1/Src/qtbase/src/plugins/sqldrivers/mysql'
    mingw32-make: *** [Makefile:52: sub-mysql-make_first] Error 2
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Might be a silly question but did you check that the architecture matches ?

    Did you build from a clean state ?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Might be a silly question but did you check that the architecture matches ?

    Did you build from a clean state ?


Log in to reply