进入下面的目录 ,查看 libqsqlmysql 明明存在,可还是报错,再看看 libqsqlmysql.so 的依赖
kyle@xianglou:~/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers$ ldd libqsqlmysql.so
linux-vdso.so.1 => (0x00007ffec56f4000)
libmysqlclient_r.so.16 => not found
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7c971ac000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f7c96f74000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f7c96d5b000)
libssl.so.10 => not found
libcrypto.so.10 => not found
libQt5Sql.so.5 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f7c96b17000)
libQt5Core.so.5 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f7c96403000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7c961e6000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7c95e64000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7c95b5b000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7c95945000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7c9557b000)
libicui18n.so.56 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f7c950e1000)
libicuuc.so.56 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f7c94d29000)
libicudata.so.56 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f7c93346000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7c93142000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f7c92f40000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7c92d38000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f7c92a27000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7c975d8000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f7c927b7000)
显示 :
libmysqlclient_r.so.16 => not found
libssl.so.10 => not found
libcrypto.so.10 => not found
这三个库依赖找不到:
解决方案
1、下载 libsqlclient_r.so.16文件后,将该文件移动到 /usr/lib/i386-linux-gnu。
64位:下载https://pan.baidu.com/s/1qO0v0WmNIH-BFn3BXyzdqQ
32位:下载https://pan.baidu.com/s/1OrsO2b5HTSGdAg7dZ-dqFA
2、对另外两个库做软链接
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so /usr/lib/x86_64-linux-gnu/libcrypto.so.10
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libssl.so.10
再次查看依赖
kyle@xianglou:~/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers$ ldd libqsqlmysql.so
./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.16: no version information available (required by ./libqsqlmysql.so)
linux-vdso.so.1 => (0x00007ffe0b75d000)
libmysqlclient_r.so.16 => /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.16 (0x00007f0285c44000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0285a2a000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f02857f2000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f02855d9000)
libssl.so.10 => /usr/lib/x86_64-linux-gnu/libssl.so.10 (0x00007f0285370000)
libcrypto.so.10 => /usr/lib/x86_64-linux-gnu/libcrypto.so.10 (0x00007f0284f2c000)
libQt5Sql.so.5 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f0284ce8000)
libQt5Core.so.5 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f02845d4000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f02843b7000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0284035000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0283d2c000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0283b16000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f028374c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0283548000)
libicui18n.so.56 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f02830ae000)
libicuuc.so.56 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f0282cf6000)
libicudata.so.56 => /home/kyle/Qt5.6.2/Tools/QtCreator/lib/Qt/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f0281313000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f0281111000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0280f09000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f0280bf8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f028639b000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f0280988000)
已经 可以 了,编译QT项目已经显示 mysql 链接成功了。