@SGaist Thanks for putting me on the right path. I solved my issue and just wanted to post what I learned for others to benefit from:
I had used install_name_tool to tell my PlugIns/sqldrivers/libqsqlmysql.dylib to find the libmysqlclient.dylib that was on my Mac (in my case installed using Homebrew). That worked fine until I deployed to other Macs and then they got the "Driver Not Loaded" error. I needed libqsqlmysql.dylib to link to something inside the app bundle.
It turns out that macdeployqt was copying libmysqlclient.dylib into my Frameworks directory (the output clearly shows this) but still, it didn't work!
3723040 vs 3773144 bytes? I was convinced this was the problem and wasted hours trying to figure it out. I still don't understand this, but it isn't the problem. It was a red herring.
The real problem is that libmysqlclient.dylib depends on those other 2 dylib's copied into the Frameworks directory by macdeployqt: libssl.1.0.0.dylib and libcrypto.1.0.0.dylib. I ran otool -L on each in turn, and found that libssl.1.0.0.dylib was depending on a copy of libcrypto.1.0.0.dylib outside the app bundle (again the homebrew location).
So, I had to fix the dependency of two dylib's mid-way through my build steps:
qmake -config release
macdeployqt MyApp.app -dmg
'make' creates MyApp.app but the Frameworks and Plugins aren't put inside it until the first execution of macdeployqt. After that, I go in and fix the dependencies:
install_name_tool -change /usr/local/Cellar/openssl/1.0.2l/lib/libcrypto.1.0.0.dylib @executable_path/../Frameworks/libcrypto.1.0.0.dylib libssl.1.0.0.dylib
install_name_tool -change /usr/local/mysql/lib/libmysqlclient.dylib @executable_path/../Frameworks/libmysqlclient.dylib libqsqlmysql.dylib
rm -rf MyApp.dmg
macdeployqt MyApp.app -dmg
After fixing the dependencies with install_name_tool, I come back to the top-level directory and delete the DMG created by that run of macdeployqt. The second time macdeployqt is executed it does not replace MyApp.app. It just complains that much of what it was going to do is done already. For example:
The second execution of macdeployqt creates the DMG with the correctly-linked dylibs.
If someone else has a similar problem, don't just copy the above steps. Use the otool -L tool on the dylibs in your app bundle to see where the dependencies are expected to be, then check to see if they are actually there. If you are deploying your app bundle to somewhere else, consider which dylib's need to be copied into your app bundle and which you can count on being on the target Mac. Finally, use install_name_tool to fix your dependencies. Hope this helps!
I'm just realizing that what I was trying to do was maybe nonsense : I was trying to pass on to the mysql server a value for the client on which my Qt program is running i.e. I was trying to "deceive" the server. And I could understand then that there would be no such method in QSqlDatabase (and that you couldn't understand my question initially).
download the Qt Sources, e.g current the sources available are qt-everywhere-opensource-src-5.5.1, After extracting
then make sure you call qmake from Qt5.5, for this purpose you can type the complete path of the qmake.
then use make and make install.
I hope it will help you.
You're understanding correctly...
Well I just had to build it on my laptop for QT 5.51 because the current version of the driver wasn't working with mysql 5.5. It was quite a simple process...
I wanted to try my program on a remote server, noticed the driver wasn't present at all, so just thought I'll build it myself to be sure it will be compatible with the version of mysql installed.
You're right, I've found the package in my distribution and it is working well. (libqt5sql5-mysql on debian jessie)
well it does call the API directly so its very close.
I was lazy and just made script to ask and run my exe.
The AutoIt compiler can make exe from file so no script runtime is needed and its very small.
But yeah, it should be fairly easy to convert since its fairly normal syntax and uses both API and
types a c++ version would.
Please search the forum about that matter. It's been answer many times already. From your description, you have a newer version the MySQL libraries than the one that have been used to build the plugin. Likely version 18 instead of 16. The fast way is to download Qt's sources and build the plugin yourself like described in the documentation.