Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMYSQL driver not loaded on mac

QMYSQL driver not loaded on mac

Scheduled Pinned Locked Moved Solved General and Desktop
mysqlmac os xqt5.9.1
43 Posts 7 Posters 22.6k Views
  • 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.
  • LuAriaL Offline
    LuAriaL Offline
    LuAria
    wrote on last edited by
    #3

    Thanks for your quick response very much !!!!
    I haved already installed MySQL. The version is 5.7.18. I can find MySQL file in /usr/local. There's only 2 folders in /opt: X11 and the other.
    I think I cannot express myself well.
    I'm using cellphone now.
    Maybe I can show my screenshots hours later.
    Thanks for your answer agian !!!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #4

      Then you have to use otool install_name_tool to change the path from /opt/etc... to your own installation of MySQL.

      [edit: fixed tool name... SGaist]

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • LuAriaL Offline
        LuAriaL Offline
        LuAria
        wrote on last edited by
        #5

        Thanks a lot.
        I think I get your point.
        Could you tell me more details of otool? thanks!
        What's more, is there no problem that use tool to change that even /opt/etc not exist in my pc?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          Sorry, I meant install_name_tool.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • LuAriaL Offline
            LuAriaL Offline
            LuAria
            wrote on last edited by
            #7

            Sorry, could you tell me the whole sentence of install_name_tool.
            I used install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/Cellar/mysql/5.7.19/lib/libmysqlclient.dylib libqsqlmysql.dylib for the Net. But it failed: error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't open file: libqsqlmysql.dylib (No such file or directory)
            I can find libmysqlclient.20.dylib and libmysqlclient.dylib both in /mysql and /mysql-5.7.18-...
            What should I do?1_1503586014967_屏幕快照 2017-08-24 下午10.44.51.png 0_1503586014966_屏幕快照 2017-08-24 下午10.44.40.png

            1 Reply Last reply
            0
            • LuAriaL Offline
              LuAriaL Offline
              LuAria
              wrote on last edited by
              #8

              I tried install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/Cellar/mysql/5.7.19/lib/libmysqlclient.20.dylib

              and it showed me: Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input

              What did it mean?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                From what you wrote, you seem to be somewhere on your filesystem and just expecting that libqsqlmysql.dylib is there.

                You have to give the full path to the Qt MySQL plugin if you're not in the folder where that file reside.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • LuAriaL Offline
                  LuAriaL Offline
                  LuAria
                  wrote on last edited by
                  #10

                  In fact, I used find ~ -iname "libqsqlmysql"*
                  and found that
                  /Users/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                  /Users/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib.dSYM
                  /Users/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF/libqsqlmysql.dylib
                  /Users/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib
                  /Users/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib.dSYM
                  /Users/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib.dSYM/Contents/Resources/DWARF/libqsqlmysql_debug.dylib
                  /Users/lujinliang/Qt5.9.1/Qt Creator.app/Contents/PlugIns/sqldrivers/libqsqlmysql.dylib

                  It seemed that 'libqsqlmysql' all in the /Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers
                  Should I use
                  install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                  to change the path
                  Thanks.

                  1 Reply Last reply
                  0
                  • LuAriaL Offline
                    LuAriaL Offline
                    LuAria
                    wrote on last edited by
                    #11

                    I used install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.20.dylib /Users/lujinliang/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                    and finally success connected.
                    I want to know whether it is the correct way.
                    Thanks.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      Yes, it is.

                      Note that when doing such a thing you have to do some testing, you are now using a client library which is from a different version that the one used to link the plugin. That may or may not work depending on the library. In this case, things look fine.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • LuAriaL Offline
                        LuAriaL Offline
                        LuAria
                        wrote on last edited by
                        #13

                        Thanks a lot.
                        Things look good.
                        Also, I want to know why QT need a strange way like /opt/local/myspl/lib/etc to connect MySQL. Is it the default way?
                        P.S. it is not a problem, I just want to know.
                        Thanks again.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          There's nothing strange here, the CI is likely using macports to get the dependencies it needs to build the plugins and macports installs its stuff by default in /opt.

                          Setting up a build machine using a package manager will always be easier than having to grab tons of installers. It's usually also simpler to handle upgrades and parallel installations with these kind of tools.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • tk421T Offline
                            tk421T Offline
                            tk421
                            wrote on last edited by
                            #15

                            I'm also using Qt 5.9 on macOS and initially had a similar problem with the MySQL driver not working, and solved it using install_name_tool very much as was described above. In my case, MySQL was installed on my Mac with Homebrew.

                            However, now that I'm deploying the application I find that it works on my development Mac but not on other Macs. This makes sense: the libqsqlmysql.dylib in the app bundle, in the Plugins/sqldrivers directory depends on finding libmysqlclient.18.dylib in the location Homebrew uses. At the same time this doesn't make sense: how could this be the right way to do this?

                            I've read a lot of posts about this issue, but haven't found anything that addresses this issue: how do I configure the plugin so that it will work on other Macs, not just ones that happen to have MySQL installed in the way I have it installed?

                            Many users of my application don't even have MySQL installed. They are using my app to connect to a MySQL server on another server. I know this should be possible, because this app worked fine for my users for several years when I had it under Qt4. I'm just encountering this question because of a necessary upgrade to Qt5.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #16

                              Copy the library in your app bundle and use install_name_tool again to point the MySQL plugin to that library.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              tk421T 1 Reply Last reply
                              0
                              • Hasan VaezH Offline
                                Hasan VaezH Offline
                                Hasan Vaez
                                wrote on last edited by Hasan Vaez
                                #17

                                Hi guys,
                                I have the same problem, but the above solutions and also all the solutions on the web do not work for me.
                                I am using Mac OS X Sierra, Qt5.9.1 installed at Home directory, Mysql 5.7.19 at /usr/local/mysql.
                                I would be pleased to help me to solve my problem on connection to QMSQL plugin.
                                I am wonder while all the new users has the same problem why Qt does not fix this bug which is seen in most of versions and claimed by many users. Half of the users' questions are about connecting to QMYSQL which is a real part of programming.
                                The error is:
                                QSqlDatabase: QMYSQL driver not loaded
                                QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                                QSqlError("", "Driver not loaded", "Driver not loaded")

                                The stuffs I have done:
                                1- hasan-mac:/ hasan$ otool -L libqsqlmysql.dylib
                                /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: 'libqsqlmysql.dylib': No such file or directory
                                2- linking the /usr/local/mysql/lib/libmysqlclient.20.dylib(and libmysqlclient.dylib) to /usr/lib
                                I think I could not run install_name_tool in the right way.
                                need your help please as I waste 2days searching the web for creating plugins and installing libs and so on...

                                regards,

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #18

                                  Hi and welcome to devnet,

                                  1. This won't work because you are calling otool in some random place where libqsqlmysql.dylib is not located. Either give the full path to the plugin or cd into the sql plugins folder in your Qt installation and call that command again.

                                  2. Likely for the same reason as number 1.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • Hasan VaezH Offline
                                    Hasan VaezH Offline
                                    Hasan Vaez
                                    wrote on last edited by Hasan Vaez
                                    #19

                                    Hi SQaist,
                                    Thank you for your prompt reply.
                                    The result on otool is:
                                    MacBook-Pro:sqldrivers hasan$ otool -L /Users/hasan/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                                    /Users/hasan/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib:
                                    libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
                                    @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.9.0, current version 5.9.1)
                                    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.9.0, current version 5.9.1)
                                    /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
                                    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
                                    /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
                                    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
                                    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
                                    0_1505932528428_Screen Shot 2017-09-20 at 11.03.42 PM.png

                                    1 Reply Last reply
                                    0
                                    • Hasan VaezH Offline
                                      Hasan VaezH Offline
                                      Hasan Vaez
                                      wrote on last edited by
                                      #20

                                      Tried to use the following command and problem solved.
                                      install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.20.dylib /Users/hasan/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

                                      The thing I am worry about is when I will face to problem as we tricked to Qt to use libqslmysql.20.dylib instead of the the one in version 18 (libmysqlclient.18.dylib).
                                      Mainly the problem is solved but it should not be OK. I am looking for a way to solve the problem in a correct way and do not want to use MACPORTS for installing the QMYSQL module. MACPORTS is a good installation package, but its size is more than 1GB in HDD and I'd prefer to use certified sourced like mysql.com website and qt.io website and so on...

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #21

                                        Then just install the package you want from whatever source suits you best and change the install_name_tool call accordingly.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        0
                                        • Hasan VaezH Offline
                                          Hasan VaezH Offline
                                          Hasan Vaez
                                          wrote on last edited by
                                          #22

                                          OK man. Thank you for your attention :)

                                          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