3

I've recently upgraded both Qt to version 5.6.0 and my Ubuntu workstation to version 16.04 LTS. Now, I know I have to recompile mysql plugin and I've successfully done it several times. However, I had problem upgrading mysql server while upgrading Ubuntu 14.04 LTS to Ubuntu 16.04 LTS and I've solved it with making backup of databases and purging and reinstalling mysql server 5.7 from Ubuntu 16.04 LTS repositories, mysql server now works fine. Then I tried to recompile qt mysql plugin with:

user@work002:/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql$ clear && make clean && /opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-Lusr/local/lib -lmysqlclient_r" mysql.pro && make all && make install

from How to Build the QMYSQL Plugin on Unix and OS X official documentation and I get following linker error:

rm -f .moc/moc_qsql_mysql_p.cpp
rm -f .moc/main.moc .moc/qsql_mysql.moc
rm -f .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o
rm -f *~ core *.core
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore main.cpp -o .moc/main.moc
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/main.o main.cpp
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore ../../../sql/drivers/mysql/qsql_mysql.cpp -o .moc/qsql_mysql.moc
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/qsql_mysql.o ../../../sql/drivers/mysql/qsql_mysql.cpp
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore ../../../sql/drivers/mysql/qsql_mysql_p.h -o .moc/moc_qsql_mysql_p.cpp
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../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,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,\$ORIGIN -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o  -L/usr/local/lib -rdynamic -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/lib -lQt5Sql -lQt5Core -lpthread  
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: error: ld returned 1 exit status
Makefile:111: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

Here is also a list of mysql related packages, retrieved with sudo dpkg -l|grep mysql:

ii  libmysqlclient-dev                            5.7.12-0ubuntu1                                     amd64        MySQL database development files
rc  libmysqlclient18:amd64                        5.5.49-0ubuntu0.14.04.1                             amd64        MySQL database client library
ii  libmysqlclient20:amd64                        5.7.12-0ubuntu1                                     amd64        MySQL database client library
ii  libmysqlclient20:i386                         5.7.12-0ubuntu1                                     i386         MySQL database client library
rc  libmysqlcppconn7                              1.1.3-5                                             amd64        MySQL Connector for C++ (library)
ii  libqt4-sql-mysql:i386                         4:4.8.7+dfsg-5ubuntu2                               i386         Qt 4 MySQL database driver
ii  mysql-client-5.7                              5.7.12-0ubuntu1                                     amd64        MySQL database client binaries
ii  mysql-client-core-5.7                         5.7.12-0ubuntu1                                     amd64        MySQL database core client binaries
ii  mysql-common                                  5.7.12-0ubuntu1                                     all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                                  5.7.12-0ubuntu1                                     all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.7                              5.7.12-0ubuntu1                                     amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.7                         5.7.12-0ubuntu1                                     amd64        MySQL database server binaries
rc  mysql-utilities                               1.6.1-2                                             all          collection of scripts for managing MySQL servers
rc  mysql-workbench-community                     6.3.6-1ubu1404                                      amd64        MySQL Workbench
ii  php-mysql                                     1:7.0+35ubuntu6                                     all          MySQL module for PHP [default]
rc  php5-mysql                                    5.5.9+dfsg-1ubuntu4.16                              amd64        MySQL module for php5
rc  php5-mysqlnd                                  5.5.9+dfsg-1ubuntu4.14                              amd64        MySQL module for php5 (Native Driver)
ii  php7.0-mysql                                  7.0.4-7ubuntu2                                      amd64        MySQL module for PHP

According to user adonis comment, I've changed compilation command to

user@work002:/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql$ make clean && /opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -llibmysqlclient" mysql.pro && make all && make install

and I get following error(s):

rm -f .moc/moc_qsql_mysql_p.cpp
rm -f .moc/main.moc .moc/qsql_mysql.moc
rm -f .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o
rm -f *~ core *.core
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore main.cpp -o .moc/main.moc
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/main.o main.cpp
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore ../../../sql/drivers/mysql/qsql_mysql.cpp -o .moc/qsql_mysql.moc
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/qsql_mysql.o ../../../sql/drivers/mysql/qsql_mysql.cpp
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore ../../../sql/drivers/mysql/qsql_mysql_p.h -o .moc/moc_qsql_mysql_p.cpp
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../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,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,\$ORIGIN -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o  -L/usr/local/lib -llibmysqlclient -rdynamic -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/lib -lQt5Sql -lQt5Core -lpthread  
/usr/bin/ld: cannot find -llibmysqlclient
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: error: ld returned 1 exit status
Makefile:111: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

Second advice from user adonis,

clear && make clean && /opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-Lusr/local/lib -lmysqlclient" mysql.pro && make all && make install,

still gives error:

rm -f .moc/moc_qsql_mysql_p.cpp
rm -f .moc/main.moc .moc/qsql_mysql.moc
rm -f .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o
rm -f *~ core *.core
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore main.cpp -o .moc/main.moc
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/main.o main.cpp
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore ../../../sql/drivers/mysql/qsql_mysql.cpp -o .moc/qsql_mysql.moc
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../mkspecs/linux-g++ -o .obj/qsql_mysql.o ../../../sql/drivers/mysql/qsql_mysql.cpp
/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/moc -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/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/mkspecs/linux-g++ -I/opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/plugins/sqldrivers/mysql -I/usr/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore ../../../sql/drivers/mysql/qsql_mysql_p.h -o .moc/moc_qsql_mysql_p.cpp
g++ -c -pipe -I/usr/include/mysql -O2 -std=c++1y -fvisibility=hidden -fvisibility-inlines-hidden -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/local/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql/5.6.0/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0 -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore/5.6.0/QtCore -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtSql -I/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/include/QtCore -I.moc -I../../../../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,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,\$ORIGIN -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlmysql.so .obj/main.o .obj/qsql_mysql.o .obj/moc_qsql_mysql_p.o  -Lusr/local/lib -lmysqlclient -rdynamic -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -L/opt/Qt/opensource/64bit/5.5/5.6/gcc_64/lib -lQt5Sql -lQt5Core -lpthread  
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: error: ld returned 1 exit status
Makefile:111: recipe for target '../../../../plugins/sqldrivers/libqsqlmysql.so' failed
make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

It must be some stupid mistake, but I simply cannot find it, why do I get this error, am I missing some package maybe?

  • 1
    libmysqlclient_r does not exist in xential. I haven't tried it, but libmysqlclient should be compatible – user448115 May 13 '16 at 21:20
  • @adonis I've upgraded the question. – KernelPanic May 13 '16 at 21:35
  • 1
    I meant something like: clear && make clean && /opt/Qt/opensource/64bit/5.5/5.6/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-Lusr/local/lib -lmysqlclient" mysql.pro && make all && make install – user448115 May 13 '16 at 22:05
  • @adonis still getting error, question updated. Do not know what to do at the moment ... – KernelPanic May 13 '16 at 22:12
  • 1
    The only thing I can think of is to replace -lmysqlclient_r with -lmysqlclient in /opt/Qt/opensource/64bit/5.5/5.6/Src/qtbase/src/sql/drivers/mysql/qsql_mysql.pri. Altough a bit hacky, it may work – user448115 May 13 '16 at 22:26
7

libmysqlclient_r.so is not part of the libmysqlclient in ubuntu 16.04. You can create a symlink to the compatible libmysqlclient.so before you run your command using:

sudo ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
0

In Kubuntu 16.04

cp /opt/Qt/5.5/gcc/plugins/sqldrivers/libqsqlmysql.so /opt/Qt/5.5/gcc/plugins/sqldrivers/libqsqlmysql.so.ori
cp /usr/lib/i386-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so  /opt/Qt/5.5/gcc/plugins/sqldrivers/libqsqlmysql.so
  • 4
    Could you explain what this does and how it solves the problem? – Zanna Sep 15 '17 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.