按照网上各种说法, ldd libqsqlmysql.so 的确是 (图取自网络,库版本可能跟实际环境不符)
libmysqlclient_r.so.16 => not found
安装mysqlclient-dev: sudo apt-get install libmysql-client-dev
cannot find -lmysqlclient_r :Method from here
# cd /usr/lib/x86_64-linux-gun (库所在目录)
# ln -s libmysqlclient.so libmysqlclient_r.so
自己生成库文件(比较懒,就不翻译了):From Here and Here
-
Go in
QTDIR/5.9.2/Src/qtbase/src/plugins/sqldrivers/mysql/
. -
Run the right
qmake
, i.e. the one coming from that installation of Qt (not the system wide one or similar). Best way to be sure is providing the full path to it:QTDIR/5.6/gcc_64/bin/qmake
. -
Run
make
. Hopefully this will just work™; if it complains about some missing libraries, install them and rerunmake
. -
This should now have produced a new
libqsqlmysql.so
plugin; overwrite the old one with this new one.
这有一点需要注意的:
需要打开mysql.pro 注释掉QMAKE_USE+=mysql 这一行
qmake 时需要加上includepath 和libs
#qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/x86-64-linux-gun/ -lmysqlclient_r" mysql.pro
make 完之后 注意命令行输出,看so输出到哪个位置了