且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Qmysql 驱动程序未加载但可用

更新时间:2022-03-24 22:24:56

重复10次:

  1. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  2. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  3. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  4. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  5. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  6. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  7. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  8. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  9. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题
  10. 我永远不会使用符号链接来解决由于不同的 soname 而导致的库丢失问题

永远永远通过符号链接解决这类问题.如果您的系统没有提供库或可执行文件所需的确切 soname,您将需要重新编译该库或可执行文件.库在其文件名中包含 soname 版本号是有原因的,不匹配的 soname 将导致动态链接器/加载器not found.您只是通过为库插入损坏的 soname 来破坏该过程和您的整个系统.

Never ever solve that kind of problems via symlinking. If your system does not provide the exact soname required by a library or an executable, you'll need to recompile that library or executable. There is a reason why libraries have the soname version number in their file names, and a mismatching soname will result in a not found for the dynamic linker/loader. You're just breaking that process and your entire system by inserting a broken soname for a library.

那么,如何重新编译插件使其在 Ubuntu 上运行?

(或者,实际上,任何地方.甚至 Windows 或 Mac.只需调整说明)

(Or, actually, anywhere. Even Windows or Mac. Just adapt the instructions)

循序渐进:

  1. 安装 mysql 开发包.在 Ubuntu 上,它应该是 libmysqlclient-dev 包,但请仔细检查是否在您的特定 Ubuntu 版本上更改了名称.继续 https://packages.ubuntu.com 并使用基于文件的搜索来查找 mysql.h.
  2. 从安装程序运行维护工具,并要求它也安装 Qt 源组件.您将在 Qt 安装目录中找到该工具.
  3. 转到INSTALL_DIR/Src/5.7/qtbase/src/plugins/sqldrivers/mysql(根据实际情况调整INSTALL_DIR5.7).
  4. 运行右边 qmake.正确的是来自相同 Qt 安装的版本,并且其版本与源代码匹配.在您的情况下,它可能位于 INSTALL_DIR/5.7/gcc_64/bin/qmake 中.
  5. 运行make.如果由于找不到某个库而导致编译失败,请在您的系统上安装所需的软件包.上面链接的 Ubuntu 软件包搜索可能有用.
  6. 一旦make运行成功,它会创建一个全新的libqsqlmysql.so.它应该会自动覆盖 INSTALL_DIR/5.7/gcc_64/plugins/sqldrivers 中的那个.如果出于某种原因它没有被自动覆盖,请手动将其移到那里.
  1. Install the mysql development packages. On Ubuntu it should be the libmysqlclient-dev package, but double check in case the name changed on your particular Ubuntu edition. Go on https://packages.ubuntu.com and use the file-based search to look for mysql.h.
  2. Run the maintanance tool from the installer, and ask it to also install the Qt source components. You'll find the tool in your Qt installation directory.
  3. Go under INSTALL_DIR/Src/5.7/qtbase/src/plugins/sqldrivers/mysql (adjust INSTALL_DIR and 5.7 to your actual case).
  4. Run the right qmake. The right one is the one coming from the same installation of Qt, and whose version matches the sources. In your case it's likely to be in INSTALL_DIR/5.7/gcc_64/bin/qmake.
  5. Run make. If it fails to compile due to some library not found, install the required packages on your system. The Ubuntu package search linked above may be useful.
  6. Once make runs successfully, it will create a brand new libqsqlmysql.so. It should automatically overwrite the one in INSTALL_DIR/5.7/gcc_64/plugins/sqldrivers. If for any reason it's not automatically overwritten, move it manually there.

完成!享受您的 MySQL 数据库连接.

Done! Enjoy your MySQL database connection.