Deploy app with mysqlplugin on OS X



  • I'm trying to solve a problem with the deployment of my Qt app on macOS. I'm having an application that is using the mysql plugin to connect to an external mysql server. The application connects fine to the server when compiled and run from within Qt creator on macOS. I can also create an application bundle with macdeployqt and run the bundled app from the same computer. But, if I try to run the same app from another computer, it does not connect to the server. I concluded, that my app is not using the bundled plugin or mysqlcientlib but the system plugin / lib instead.
    And here my troubles begin. How could I debug the problem? (edited) And how would I make my app use the bundled driver / lib?

    Some Infos on what I did so far:

    # Installed Qt 5.12 (the binary build)
    cd /Users/daniel/Qt/5.12.1/Src
    ./configure -opensource -confirm-license -sql-mysql
    # checked the following output lines: 
    # Qt Sql Drivers:
    #   MySql .................................. yes
    cd /Users/daniel/Qt/5.12.1/Src/qtbase/src/plugins/sqldrivers/mysql
    /Users/daniel/Qt/5.12.1/clang_64/bin/qmake
    make
    make install
    # compiled my app in Qt creator as "release" build
    # ran the macdeployqt command. Pseudo code:
    <macdeployqt> <app-path> -qmldir=<qml-path>
    # only got few errors:
    ERROR: no file at "/usr/local/opt/libiodbc/lib/libiodbc.2.dylib"
    ERROR: no file at "/Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib"
    

    My app bundle contains "libmysqlclient.21.dylib" in "Contents/Framework" and also "libqsqlmysql.dylib" in "Contents/Pugins/sqldrivers"
    Documentation states that I can get debug messages from plugins by setting the appropiate environment variable. As I only use mac to deploy my software; where would I set that environment variable for my app and how could I get any debug output?

    Edit: found the answer to that part:
    The environment variable can be set with

    qputenv("QT_DEBUG_PLUGINS", "1");
    

    An own message handler can be installed according to the example in the help for qInstallMessageHandler. Then the output can be written to any file.


  • Lifetime Qt Champion

    Hi,

    In the terminal and you launch your application from within the bundle.

    You should also take into account that depending on where the MySQL server is located, it must be configured to allow connection from the outside.



  • @SGaist editing at the same time :-). The server allows connections, as I can access other databases from the same machine. I'll check on Monday, what plugins are actually loaded.



  • The 'recipe' in my first post seems to work. Further testing confirmed that. My troubles have been related to me recompiling the qtbase module locally without mysql support. Marking the question as solved.


  • Lifetime Qt Champion

    Thanks for the feedback !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.