Qt官方文档
How to Build the QMYSQL Plugin on Unix and macOS
stackoverflow上的一个参考
Qt C++ QMYSQL driver not loaded on MacOS - Tutorial for building QMYSQL Plugin
Github上的一个脚本
Build and Install MySQL Plugin for QT on MacOS
但是有个问题,我是通过brew
安装Qt的。解决办法也很简单。无需源码编译。
1 | brew install qt-mysql |
一个note
In #9117, we switched to a new prefix of /opt/homebrew for installations on Apple Silicon. This was written and shipped with heroic speed to help prevent strange issues with bleeding edge users on the first consumer Apple Silicon Macs.
使用命令
1 | qmake -query QT_INSTALL_PREFIX |
查询到的Qt安装路径为/opt/homebrew
针对<qt_installation_path>/Src/qtbase/src/plugins/sqldrivers
1 | ls $(qmake -query QT_INSTALL_PREFIX) |
可以观察到没有Src
这个文件夹。
实际的驱动库的目录在这/opt/homebrew/Cellar/qt/6.4.2_1/share/qt/plugins/sqldrivers