Error when use mysql library

  • Hi everybody
    I got error when compile project with mysql
    C:\Users\illunara\Documents\gui\main.cpp:-1: error: undefined reference to `qt_static_plugin_qsqlmysql()'

    I'm had
    win7 ultimate x64
    build Qt 5.4.2 mingw491 static
    build sqldriver for qt and copy it into QtStatic\plugin\sqldrivers
    copy libmysqll.dll to windows's folder

    And here is my .pro file

    TEMPLATE = app

    QT += qml quick sql network xml

    QMAKE_CXXFLAGS += -std=c++0x

    RC_FILE = gui.rc

    RESOURCES += qml.qrc

    CONFIG += static plugin



    It works fine with dynamic Qt through. Was i missing something? Thanks

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You can find more information about static plugin handling here

  • @SGaist Thank for a warm-heart welcoming
    Since i still new to QT, can you give me more detail please?
    I look into Plug & Paint example as you suggest
    LIBS = -Lplugins -lpnp_basictools
    What does this command do, and where can i read about its syntax?

  • Lifetime Qt Champion

    I was pointing the part containing

    QTPLUGIN     += qjpeg \
                    qgif \

    That, you have to add QTPLUGIN in your pro file with the plugins your application uses.

  • Thank for your reply
    I tried to follow the example and add those line to pro
    CONFIG += static console
    QTPLUGIN += qsqlmysql

    in main.cpp

    The compiler keep telling me that
    "Plugin class name could not be determined for qsqlmysql plugin."
    I compiled mysql plugin and put qsqlmysql.dll, qsqlmysqld.dll into qt static plugin folder

    It works well on non-static QT through :(

  • Lifetime Qt Champion

    Since you are building Qt yourself anyway, the simplest thing to do with the SQL plugins is to use the "built-in" Qt option so they are directly in.

  • @SGaist I found this on the windows-build-qt-static script

    configure.bat -static -debug-and-release -platform win32-g++ -prefix $QtDir -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -no-openssl
    -opensource -confirm-license `
    -make libs -nomake tools -nomake examples -nomake tests

    Should i add -qt-sql-mysql flag?

  • Lifetime Qt Champion

    Yes, however, don't forget the licensing implication of a static build.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.