我最近将 升级Qt
到了 版本5.6.0
,并将Ubuntu
工作站升级到了 版本16.04 LTS
。现在,我知道我必须重新编译mysql plugin
,而且我已经成功地完成了几次。然而,我问题升级 mysql server
升级Ubuntu 14.04 LTS
到时Ubuntu 16.04 LTS
,我通过备份数据库、清除存储库并重新安装解决了这个问题mysql server 5.7
,Ubuntu 16.04 LTS
现在mysql server
运行正常。然后我尝试qt mysql plugin
使用以下命令重新编译:
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
从如何在 Unix 和 OS X 上构建 QMYSQL 插件官方文档我得到了以下链接器错误:
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
以下是mysql
相关包,检索到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
根据用户 adonis 评论,我已compilation command
改为
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
我收到以下错误:
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
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
,
仍然出现错误:
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
这肯定是某个愚蠢的错误,但我就是找不到它,为什么我会收到这个错误,是不是我缺少了某个包?
答案1
libmysqlclient_r.so
不是 ubuntu 16.04 的一部分。您可以在运行命令之前使用以下命令libmysqlclient
创建兼容的符号链接:libmysqlclient.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
答案2
在 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