Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt cannot connect to mysql, libqsqlmysql.dylib is not loading. HELP please.
Forum Updated to NodeBB v4.3 + New Features

Qt cannot connect to mysql, libqsqlmysql.dylib is not loading. HELP please.

Scheduled Pinned Locked Moved Installation and Deployment
7 Posts 2 Posters 7.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abdol
    wrote on last edited by
    #1

    Hi every one. This is my first post in this forum. I hope someone gives me some clues on how to resolve this issue.
    I have gone through the documentation of building Qt and mysql, I also built the the drivers successfully but after installing them in the correct directory I can't see mysql driver in the out put string.

    please see this link for further info:
    http://www.qtcentre.org/threads/42394-can-not-connect-to-mysql-using-Qt-help-me-please

    I have built the qt libraries and qt creator on my computer (using the method recommended in the Qt documentation, qmake, make, ...)

    I also compiled mysql on my computer using mysql online documentation:

    http://doc.qt.nokia.com/latest/sql-driver.html#qmysql

    I managed to create libqsqlmysql.dylib and libqsqlmysql_debug.dylib and installed them in

    /usr/local/Trolltech/Qt-4.7.3/plugins/sqldrivers

    where my qt is installed. when i run the following code
    @
    #include <QtCore/QCoreApplication>
    #include <QtSql>
    #include <QtDebug>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    QSqlDatabase * db = new QSqlDatabase;

    qDebug() << db->drivers();
    qDebug() << QCoreApplication::libraryPaths();
    return 1;
    }@
    

    i only get
    ("QSQLITE", "QODBC3", "QODBC")

    why mysql's driver is not loading?

    These three drivers in addition to the one that I installed are all there. Here is ls result:

    dhcp-85-5:sqldrivers ***$ ls
    libqsqlite.dylib libqsqlmysql_debug.dylib
    libqsqlite_debug.dylib libqsqlodbc.dylib
    libqsqlmysql.dylib libqsqlodbc_debug.dylib

    I used otool before and this is what i got:
    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/local/Trolltech/Qt-4.7.3/lib/QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.3)
    /usr/local/Trolltech/Qt-4.7.3/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.3)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 830.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)

    i also tried echo $DYLD_LIBRARY_PATH and i get empty string. Would you please tell me what value this should be set to?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Just a guess: libmysqlclient.18.dylib cannot be found. Add the path to the directory containing libmysqlclient.18.dylib to DYLD_LIBRARY_PATH.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        abdol
        wrote on last edited by
        #3

        Thank you Volker,
        My question is I don't know where to go and set DYLD_LIBRARY_PATH.
        When I use terminal (bash) in mac it only sets it for the current terminal and when I close it every thing is gone.

        There should be a file somewhere so that I can edit it for the user or globally but i don't know its name and location

        can you help me with that please.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          The best way would be to copy the lib into the frameworks folder inside the app and use install_name_tool to change the path. Have a look at the "Mac Deployment":http://developer.qt.nokia.com/doc/qt-4.7/deployment-mac.html page of the Qt docs on some information how to do this.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            abdol
            wrote on last edited by
            #5

            Thank you Volker :),
            I solved the problem. You were right, I used ln to put a link of libmysqlclient.18.dylib in mac's lib folder.
            Also the link you just put is awesome. Thanks a lot.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              If you want to ship that application to someone else, you'd better put the libs into the application bundle (if allowed by the license, of course).

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • A Offline
                A Offline
                abdol
                wrote on last edited by
                #7

                I appreciate your helps and consider this. Thank you so much :)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved