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

mysql driver not loaded



  • hi ,

    opareting system ubuntu 15.4 and xammp working on it.
    i can use mysql with php but i cant use with qt desktop application.
    when i try to compile mysql.pro file result is

    <code>
    /usr/bin/ld: cannot find -lssl
    /usr/bin/ld: cannot find -lcrypto
    collect2: error: ld returned 1 exit status
    Makefile:131: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
    make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

    </code


  • Qt Champions 2019

    You need to install development packages for SSL and Crypto (libssl-dev, and I guess libcrypto++-dev)



  • thnx jsulm. i try to your advice and i have an other error message

    <code>
    make
    rm -f libqsqlmysql.so
    g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-rpath,/opt/Qt/5.5/gcc_64 -Wl,-rpath,/opt/Qt/5.5/gcc_64 -Wl,-rpath,/opt/Qt/5.5/gcc_64/lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o -L/usr/lib/x86_64-linux-gnu -rdynamic -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/opt/Qt/5.5/gcc_64/lib -lQt5Sql -lQt5Core -lpthread
    .obj/qsql_mysql.o: In function QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&)': qsql_mysql.cpp:(.text+0x2134): undefined reference toQString::simplified_helper(QString const&)'
    qsql_mysql.cpp:(.text+0x2173): undefined reference to QString::simplified_helper(QString&)' qsql_mysql.cpp:(.text+0x21ad): undefined reference toQString::simplified_helper(QString&)'
    qsql_mysql.cpp:(.text+0x2c3b): undefined reference to QString::simplified_helper(QString&)' .obj/qsql_mysql.o: In functionQMYSQLResult::handle() const':
    qsql_mysql.cpp:(.text+0x43af): undefined reference to QMetaType::registerNormalizedType(QByteArray const&, void (*)(void*), void* (*)(void*, void const*), int, QFlags<QMetaType::TypeFlag>, QMetaObject const*)' .obj/qsql_mysql.o: In functionint qRegisterNormalizedMetaType<st_mysql_res*>(QByteArray const&, st_mysql_res**, QtPrivate::MetaTypeDefinedHelper<st_mysql_res*, QMetaTypeId2<st_mysql_res*>::Defined&&(!QMetaTypeId2<st_mysql_res*>::IsBuiltIn)>::DefinedType)':
    qsql_mysql.cpp:(.text._Z27qRegisterNormalizedMetaTypeIP12st_mysql_resEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE[_Z27qRegisterNormalizedMetaTypeIP12st_mysql_resEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE]+0x4a): undefined reference to QMetaType::registerNormalizedType(QByteArray const&, void (*)(void*), void* (*)(void*, void const*), int, QFlags<QMetaType::TypeFlag>, QMetaObject const*)' .obj/qsql_mysql.o: In functionint qRegisterNormalizedMetaType<st_mysql*>(QByteArray const&, st_mysql**, QtPrivate::MetaTypeDefinedHelper<st_mysql*, QMetaTypeId2<st_mysql*>::Defined&&(!QMetaTypeId2<st_mysql*>::IsBuiltIn)>::DefinedType)':
    qsql_mysql.cpp:(.text._Z27qRegisterNormalizedMetaTypeIP8st_mysqlEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE[_Z27qRegisterNormalizedMetaTypeIP8st_mysqlEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE]+0x4a): undefined reference to `QMetaType::registerNormalizedType(QByteArray const&, void ()(void), void* ()(void, void const*), int, QFlagsQMetaType::TypeFlag, QMetaObject const*)'
    collect2: error: ld returned 1 exit status
    Makefile:131: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
    make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1
    mehmet@mehmet-GA-MA785GT-UD3H:/opt/Qt/5.5/Src/qtbase/src/plugins/sqldrivers/mysql$

    </code>


  • Lifetime Qt Champion

    Hi,

    Which version of the sources are you using ?



  • Hi SGaist

    MySQL version 5.6.26 , QT 5.5



  • <code>
    20:38:44: Running steps for project mysql...
    20:38:44: Configuration unchanged, skipping qmake step.
    20:38:44: Starting: "/usr/bin/make"
    g++ -c -pipe -I/usr/include/mysql -O2 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x -fno-exceptions -Wall -W -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_TSLIB -DQT_NO_LIBINPUT -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. -I/usr/include/mysql -I/opt/Qt/5.5/gcc_64/include/QtCore/5.5.0 -I/opt/Qt/5.5/gcc_64/include/QtCore/5.5.0/QtCore -I/opt/Qt/5.5/gcc_64/include/QtSql/5.5.0 -I/opt/Qt/5.5/gcc_64/include/QtSql/5.5.0/QtSql -I/opt/Qt/5.5/gcc_64/include -I/opt/Qt/5.5/gcc_64/include/QtSql -I/opt/Qt/5.5/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/main.o main.cpp
    In file included from main.cpp:67:0:
    main.moc:12:2: error: #error "This file was generated using the moc from 4.8.6. It"
    #error "This file was generated using the moc from 4.8.6. It"
    ^
    main.moc:13:2: error: #error "cannot be used with the include files from this version of Qt."
    #error "cannot be used with the include files from this version of Qt."
    ^
    main.moc:14:2: error: #error "(The moc has changed too much.)"
    #error "(The moc has changed too much.)"
    ^
    main.moc:46:7: error: 'QMetaObjectExtraData' does not name a type
    const QMetaObjectExtraData QMYSQLDriverPlugin::staticMetaObjectExtraData = {
    ^
    main.moc:52:41: error: 'staticMetaObjectExtraData' was not declared in this scope
    qt_meta_data_QMYSQLDriverPlugin, &staticMetaObjectExtraData }
    ^
    main.moc: In member function 'virtual const QMetaObject* QMYSQLDriverPlugin::metaObject() const':
    main.moc:61:71: error: conditional expression between distinct pointer types 'QDynamicMetaObjectData*' and 'const QMetaObject*' lacks a cast
    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
    ^
    main.moc:62:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    Makefile:874: recipe for target '.obj/main.o' failed
    make: *** [.obj/main.o] Error 1
    20:38:45: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project mysql (kit: Desktop Qt 5.5.0 GCC 64bit)
    When executing step "Make"
    20:38:45: Elapsed time: 00:01.
    </code>


  • Lifetime Qt Champion

    You're not calling the right qmake. Looks like the Qt 4 version of qmake is called.



  • qmake location : /opt/Qt/5.5/gcc_64/bin/qmake

    how can fix moc error .

    main.moc:12:2: error: #error "This file was generated using the moc from 4.8.6. It"
    #error "This file was generated using the moc from 4.8.6. It"


  • Lifetime Qt Champion

    Did you first call moc on the command line before trying to build with Qt Creator ?

    If so, do a full rebuild.



  • Hi .
    i solved problem.

    1. step unistall Qt
    2. reinstall again. and its working for me.

Log in to reply