Important: Please read the Qt Code of Conduct -

[SOLVED][MySql] Problem with compilling plugin

  • Hi,

    I got a problem with compilling mysql pluging for Qt5.2.1. I use ubuntu 12.04 and i got both qt4 and qt5 installed. Qt 4 is installed from repositories and Qt 5 from online installer. Now I need to compile mysqli plugin for my qt5, but I got a problem there. I use these commands:
    @cd ~/qt-everywhere-opensource-src-5.2.1/qtbase/src/plugins/sqldrivers/mysql
    ~/QtSDK is the folder where Qt 5.2.1 is installed, so I figured out that i need to use qmake from this version.
    After that I use make command and there I got a problem, see result below:
    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_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../../../../mkspecs/linux-g++ -I. -I/work/build/icu_install/include -I/home/alek/QtSDK/5.2.1/gcc_64/include/QtSql/5.2.1 -I/home/alek/QtSDK/5.2.1/gcc_64/include/QtSql/5.2.1/QtSql -I/home/alek/QtSDK/5.2.1/gcc_64/include -I/home/alek/QtSDK/5.2.1/gcc_64/include/QtSql -I/home/alek/QtSDK/5.2.1/gcc_64/include/QtCore/5.2.1 -I/home/alek/QtSDK/5.2.1/gcc_64/include/QtCore/5.2.1/QtCore -I/home/alek/QtSDK/5.2.1/gcc_64/include/QtCore -I.moc -o .obj/main.o main.cpp
    In file included from main.cpp:76:0:
    main.moc:13:2: error: #error "This file was generated using the moc from 4.8.1. It"
    main.moc:14:2: error: #error "cannot be used with the include files from this version of Qt."
    main.moc:15:2: error: #error "(The moc has changed too much.)"
    main.moc:47:7: error: ‘QMetaObjectExtraData’ does not name a type
    main.moc:53:41: error: ‘staticMetaObjectExtraData’ was not declared in this scope
    main.moc: In member function ‘virtual const QMetaObject* QMYSQLDriverPlugin::metaObject() const’:
    main.moc:62:71: error: conditional expression between distinct pointer types ‘QDynamicMetaObjectData*’ and ‘const QMetaObject*’ lacks a cast
    main.moc:63:1: warning: control reaches end of non-void function [-Wreturn-type]
    make: *** [.obj/main.o] Błąd 1


    Thanks in advance

  • Hi,
    there's a mix between both Qt versions.
    main.moc:13:2: error: #error "This file was generated using the moc from* 4.8.1.* It"

    Try to build the project completely new.

  • Oh right I managed to compile it. But still cannot use it in my project
    @QSqlDatabase: QMYSQL driver not loaded@
    What do I need to do to make it work?

    EDIT: Found it, I needed to copy it from the place it was compilled to QtSDK folder.

  • There are tons of posts in the forum related to that message but mostly concerning Win7.
    Have you tried to compile one of the Qt samples e.g. SQL browser?
    And does it produce the same message?
    Do you have the newest MYSQL (64-Bit) installed?

  • I solved it on my own. I needed to copy compilled version from @~/qt-everywhere-opensource-src-5.2.1/qtbase/plugins/sqldrivers@ to @~/QtSDK/5.2.1/gcc_64/plugins/sqldrivers@ It works perfectly now and I can connect to mysql database.

    Anyway, thanks for help

Log in to reply