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

How to built MySQL driver on Ubuntu 18



  • hello,
    I'm a new Qter ,working on Ubuntu 18.04 and My sql 8.0
    I am trying to build Qt 5.11.2 x64 with MySQL driver .but i met lots of error.
    fellowing Qt Documentation http://doc.qt.io/qt-5/sql-driver.html#building-the-drivers
    using qt configure met this pic
    0_1538054590198_7510c21b-9957-4864-b6d2-2e20ed3b2e58-image.png
    then i trying to open qtbase-everywhere-src-5.11.2/src/plugins/sqldrivers/mysql and qmake
    0_1538054746010_fa51bf86-fc91-4942-9545-774a95570bef-image.png
    How do I solve this problem?



  • @Xping
    Since you say you are new: just verifying, you really want to build MySQL drivers, you cannot just use the ones available pre-compiled for Ubuntu? Because that's a lot easier....



  • @JonB
    how to build it?


  • Lifetime Qt Champion

    Hi,

    It's explained here



  • Same here,

    I built the drivers:

    diicic@diicic-MS-7B45:/var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers$ sudo /var/opt/Qt/5.11.2/gcc_64/bin/qmake sqldrivers.pro 
    
    Running configuration tests...
    Done running configuration tests.
    
    Configure summary:
    
    Qt Sql:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. yes
      OCI (Oracle) ........................... no
      ODBC ................................... no
      PostgreSQL ............................. no
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    
    Qt is now configured for building. Just run 'make'.
    Once everything is built, Qt is installed.
    You should NOT run 'make install'.
    Note that this build cannot be deployed to other machines or devices.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    
    diicic@diicic-MS-7B45:/var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers$ sudo make
    cd mysql/ && ( test -e Makefile || /var/opt/Qt/5.11.2/gcc_64/bin/qmake -o Makefile /var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro ) && make -f Makefile 
    make[1]: Entering directory '/var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/mysql'
    g++ -c -pipe -O2 -g -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -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. -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2/QtCore -I/var/opt/Qt/5.11.2/gcc_64/include -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore -I.moc -isystem /usr/include/mysql -I/var/opt/Qt/5.11.2/gcc_64/mkspecs/linux-g++ -o .obj/qsql_mysql.o qsql_mysql.cpp
    g++ -pipe -O2 -g -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -dM -E -o .moc/moc_predefs.h /var/opt/Qt/5.11.2/gcc_64/mkspecs/features/data/dummy.cpp
    /var/opt/Qt/5.11.2/gcc_64/bin/moc -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 --include /var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/mysql/.moc/moc_predefs.h -I/var/opt/Qt/5.11.2/gcc_64/mkspecs/linux-g++ -I/var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/mysql -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2/QtCore -I/var/opt/Qt/5.11.2/gcc_64/include -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include main.cpp -o .moc/main.moc
    g++ -c -pipe -O2 -g -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -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. -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2/QtCore -I/var/opt/Qt/5.11.2/gcc_64/include -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore -I.moc -isystem /usr/include/mysql -I/var/opt/Qt/5.11.2/gcc_64/mkspecs/linux-g++ -o .obj/main.o main.cpp
    /var/opt/Qt/5.11.2/gcc_64/bin/moc -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 --include /var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/mysql/.moc/moc_predefs.h -I/var/opt/Qt/5.11.2/gcc_64/mkspecs/linux-g++ -I/var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/mysql -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2/QtCore -I/var/opt/Qt/5.11.2/gcc_64/include -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include qsql_mysql_p.h -o .moc/moc_qsql_mysql_p.cpp
    g++ -c -pipe -O2 -g -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -D_REENTRANT -fPIC -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. -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql/5.11.2/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2 -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore/5.11.2/QtCore -I/var/opt/Qt/5.11.2/gcc_64/include -I/var/opt/Qt/5.11.2/gcc_64/include/QtSql -I/var/opt/Qt/5.11.2/gcc_64/include/QtCore -I.moc -isystem /usr/include/mysql -I/var/opt/Qt/5.11.2/gcc_64/mkspecs/linux-g++ -o .obj/moc_qsql_mysql_p.o .moc/moc_qsql_mysql_p.cpp
    rm -f libqsqlmysql.so
    g++ -Wl,--no-undefined -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../../lib -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/qsql_mysql.o .obj/main.o .obj/moc_qsql_mysql_p.o  -L/var/opt/Qt/5.11.2/gcc_64/lib -lQt5Sql -lQt5Core -lpthread -lmysqlclient  
    mv -f libqsqlmysql.so ../plugins/sqldrivers/libqsqlmysql.so
    objcopy --only-keep-debug ../plugins/sqldrivers/libqsqlmysql.so ../plugins/sqldrivers/libqsqlmysql.so.debug && objcopy --strip-debug ../plugins/sqldrivers/libqsqlmysql.so && objcopy --add-gnu-debuglink=../plugins/sqldrivers/libqsqlmysql.so.debug ../plugins/sqldrivers/libqsqlmysql.so && chmod -x ../plugins/sqldrivers/libqsqlmysql.so.debug
    

    but error still shows up. Also if I ldd mysqldrivers.so:

    diicic@diicic-MS-7B45:/var/opt/Qt/5.11.2/Src/qtbase/src/plugins/sqldrivers/mysql$ ldd /var/opt/Qt/5.11.2/gcc_64/plugins/sqldrivers/libqsqlmysql.so
    	linux-vdso.so.1 (0x00007ffc497ee000)
    	libQt5Sql.so.5 => /var/opt/Qt/5.11.2/gcc_64/plugins/sqldrivers/../../lib/libQt5Sql.so.5 (0x00007f1a48de3000)
    	libQt5Core.so.5 => /var/opt/Qt/5.11.2/gcc_64/plugins/sqldrivers/../../lib/libQt5Core.so.5 (0x00007f1a48689000)
    	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1a4846a000)
    	**libmysqlclient.so.18 => not found**
    	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1a480e1000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1a47d43000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1a47b2b000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1a4773a000)
    	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1a4751d000)
    	libicui18n.so.56 => /var/opt/Qt/5.11.2/gcc_64/plugins/sqldrivers/../../lib/libicui18n.so.56 (0x00007f1a47084000)
    	libicuuc.so.56 => /var/opt/Qt/5.11.2/gcc_64/plugins/sqldrivers/../../lib/libicuuc.so.56 (0x00007f1a46ccc000)
    	libicudata.so.56 => /var/opt/Qt/5.11.2/gcc_64/plugins/sqldrivers/../../lib/libicudata.so.56 (0x00007f1a452e9000)
    	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1a450e5000)
    	libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f1a44ee3000)
    	libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f1a44bcd000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f1a4923e000)
    	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f1a4495b000)
    

    regards,

    Dani.


  • Lifetime Qt Champion

    Hi,

    You didn't install the version you built.


Log in to reply