Unable to connect to Mysql on Mac



  • I've searched a lot for a nice new Development Tool and was just so happy to find Qt. But now it seems impossible to get it work properly.

    Since days i've tried to successfully connect to my mysql server, the driver in plugin/sqldrivers/ is around but not loaded in the example application sql browser.

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QMYSQL QMYSQL3 QSQLITE QODBC QODBC3 QPSQL QPSQL7

    I've tried to copy existing libs to project folder ect. and rebuilding the driver, which doesn't work since the file-linkages are severely messed up, seems to be from a different directory-tree-structure. All the tips i found were on older versions or different os.
    I'm using Qt 5.2 and OSx 10.7

    Desperate and very thankful for any advice what to do to get the example running on osx !!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Did you install MySQL for OS X ?



  • Yes, server and connector up and running, latest builds.


  • Lifetime Qt Champion

    what does otool -L on libqsqlmysql.dylib return ?



  • Allready checked, all covered in the specific places. But for the record…

    libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)

    /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)

    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)

    /Users/**/Qt/5.2.0/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.2.0, current version 5.2.0)

    /Users/**/Qt/5.2.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.2.0, current version 5.2.0)

    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)

    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

    Thnx a lot!


  • Lifetime Qt Champion

    Then what error does QSqlDatabase return ?



  • QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QMYSQL QMYSQL3 QSQLITE QODBC QODBC3 QPSQL QPSQL7


  • Lifetime Qt Champion

    Sorry, I meant the QSqlDatabase::error function



  • QSqlError.text is "Driver not loaded"… not sure that's what you meant.


  • Lifetime Qt Champion

    Yes that's it but I was hoping for more information since you have the plugin that seems to be built correctly.

    Did you build it yourself ?



  • Not yet, because it didn't work at all. I thought it evt. could work since it comes in the package… however. I'm trying to build it again. After downgrading my server to mysql 5.5 version and adjusting the suggested links from the program internal help I'm stuck again:
    qsql_mysql.o only in 32bit but it automatically tries to build in 64bit clang…

    omg


  • Lifetime Qt Champion

    Are you trying to build the plugin in 32 bit ? Qt's in 64 bit by default



  • It tries to build in 64 with clang 64, but it claims qsql_mysql.o coming with Qt src is only 32bit and stops building because of that…


  • Lifetime Qt Champion

    How did you install Qt ?



  • Hello again.
    Now i managed to build the plugin successfully with latest versions.
    But still the sample sqlbrowser doesn't load the driver.

    I also checkt all dependencies and tried having a copy of the driver libqsqlmysql.dylib and libqsqlmysql_debug.dylib as well as libmysqlclient.18.dylib to the project folder.

    desperate again… a big thnx for any hints in advance!!



  • I'm working on osX 10.8.5, Qt Creator 3.01 (based on Qt 5.2.1 clang-64)
    the driver is based on the same version src for sql-drivers and mysql 5.6.17 (x86_64) also properly working with workbench on localhost…

    the only thing could be that libmysqlclient.18.dylib wasn't built with clang-64. but how to solve that? the linker worked properly.


  • Lifetime Qt Champion

    They must not be in the same folder as the application. Qt looks for the plugins in specific folders. What you must ensure is that llibqsqlmysql can get to libmysqlclient what does otool -L on both libraries return ?



  • Of course, putting them in the same folder as the project was an act of desperation. The links i've checked and all seemed fine to me - i found all the required files in pace.
    The output of otool -L for libmysqlclient and libqsqlmysql in the clang_64/plugins/sqlservers folder:

    libmysqlclient.18.dylib:
    libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

    libqsqlmysql.dylib:
    libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
    libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /Users/br/Qt521/5.2.1/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.2.0, current version 5.2.1)
    /Users/br/Qt521/5.2.1/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.2.0, current version 5.2.1)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)


  • Lifetime Qt Champion

    The id of libmysqlclient.18.dylib is just libmysqlclient.18.dylib so you either need to add the path containing that lib to DYLD_LIBRARY_PATH or update the id to use the full path to it.



  • You're my hero of the week!!
    Thanks a lot!
    b


Log in to reply
 

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