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
Forum Updated to NodeBB v4.3 + New Features

QMYSQL driver not loaded on mac

Scheduled Pinned Locked Moved Solved General and Desktop
mysqlmac os xqt5.9.1
43 Posts 7 Posters 22.7k Views 3 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.
  • S SGaist
    14 Sept 2017, 19:53

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

    T Offline
    T Offline
    tk421
    wrote on 23 Sept 2017, 03:45 last edited by
    #23

    @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!

    ls -l Frameworks/*dylib
     -rw-r--r--  1   1919816 22  libcrypto.1.0.0.dylib
     -rw-r--r--  1   3723040 22  libmysqlclient.dylib
     -rw-r--r--  1    375376 22  libssl.1.0.0.dylib
    

    The first thing I noticed about this was that the file size of libmysqlclient.dylib was smaller after the copy:

    /usr/local/Cellar/mysql/5.7.18/lib/libmysqlclient.dylib -> libmysqlclient.20.dylib
    /usr/local/Cellar/mysql/5.7.18/lib/libmysqlclient.20.dylib  3773144
    

    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:

    make clean
    qmake -config release
    make
    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:

    cd MyApp.app/Contents/Frameworks
    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
    cd ../PlugIns/sqldrivers
    install_name_tool -change /usr/local/mysql/lib/libmysqlclient.dylib @executable_path/../Frameworks/libmysqlclient.dylib libqsqlmysql.dylib
    cd ../../../..
    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:

    File exists, skip copy: "MyApp.app/Contents/PlugIns/sqldrivers/libqsqlmysql.dylib"
    

    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!

    1 Reply Last reply
    1
    • A Offline
      A Offline
      Amit Talbot
      wrote on 23 Oct 2017, 18:03 last edited by
      #24

      im using qt 5.9 and isolated install on mysql 5.7.20 on mac this piece of code worked like charm for me

      brew install mysql-connector-c
      

      I already had MAMP installed.... and wanted to use the mysql from mamp running on port 8889 this code helped me to do that

      ```
      

      db.setHostName("localhost");
      db.setConnectOptions("UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock");
      db.setDatabaseName("xxxxxx");
      db.setUserName("root");
      db.setPassword("root");
      db.setPort(8889);

      1 Reply Last reply
      0
      • E Offline
        E Offline
        edwinxxxx
        wrote on 1 Aug 2019, 08:16 last edited by edwinxxxx 8 Jan 2019, 08:19
        #25

        Hi, what i have done are as pervious.but it shows that

        //-bash: /Users/lucas/Qt5.9.8/5.9.8/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: cannot execute binary file"
        

        how can i fix it? thx for your help:)

        J 1 Reply Last reply 1 Aug 2019, 08:22
        0
        • E edwinxxxx
          1 Aug 2019, 08:16

          Hi, what i have done are as pervious.but it shows that

          //-bash: /Users/lucas/Qt5.9.8/5.9.8/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: cannot execute binary file"
          

          how can i fix it? thx for your help:)

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 1 Aug 2019, 08:22 last edited by
          #26

          @edwinxxxx said in QMYSQL driver not loaded on mac:

          /Users/lucas/Qt5.9.8/5.9.8/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

          You can't execute a library.
          What are you trying to do?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          E 1 Reply Last reply 1 Aug 2019, 08:29
          0
          • J jsulm
            1 Aug 2019, 08:22

            @edwinxxxx said in QMYSQL driver not loaded on mac:

            /Users/lucas/Qt5.9.8/5.9.8/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

            You can't execute a library.
            What are you trying to do?

            E Offline
            E Offline
            edwinxxxx
            wrote on 1 Aug 2019, 08:29 last edited by edwinxxxx 8 Jan 2019, 08:31
            #27

            @jsulm coz mysql driver can't be loaded in qt creator , i followed the directions above which has been proved that it was a successful way to solve the problem.but error happens.

            J 1 Reply Last reply 1 Aug 2019, 08:31
            0
            • E edwinxxxx
              1 Aug 2019, 08:29

              @jsulm coz mysql driver can't be loaded in qt creator , i followed the directions above which has been proved that it was a successful way to solve the problem.but error happens.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 1 Aug 2019, 08:31 last edited by
              #28

              @edwinxxxx Please tell us the exact step your executing when you get that error message

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              E 1 Reply Last reply 1 Aug 2019, 08:40
              0
              • J jsulm
                1 Aug 2019, 08:31

                @edwinxxxx Please tell us the exact step your executing when you get that error message

                E Offline
                E Offline
                edwinxxxx
                wrote on 1 Aug 2019, 08:40 last edited by
                #29

                @jsulm 0_1564648798567_屏幕快照 2019-08-01 16.34.23.png

                J 1 Reply Last reply 1 Aug 2019, 08:43
                0
                • E edwinxxxx
                  1 Aug 2019, 08:40

                  @jsulm 0_1564648798567_屏幕快照 2019-08-01 16.34.23.png

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 1 Aug 2019, 08:43 last edited by
                  #30

                  @edwinxxxx The last thig you did does not make sense: you're trying to execute a lib.
                  The first one was not successful - you called it in a wrong way. Take a look at its output ("Usage:"), it explains how to call it.
                  @SGaist - you're the Mac expert, can you take a look?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    edwinxxxx
                    wrote on 1 Aug 2019, 08:51 last edited by
                    #31

                    @jsulm thanks for your tips.i have wasted the whole day to solve it😂

                    S 1 Reply Last reply 1 Aug 2019, 13:26
                    0
                    • E edwinxxxx
                      1 Aug 2019, 08:51

                      @jsulm thanks for your tips.i have wasted the whole day to solve it😂

                      S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 1 Aug 2019, 13:26 last edited by
                      #32

                      @edwinxxxx so it's now working correctly ?

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

                      E 1 Reply Last reply 2 Aug 2019, 01:19
                      0
                      • S SGaist
                        1 Aug 2019, 13:26

                        @edwinxxxx so it's now working correctly ?

                        E Offline
                        E Offline
                        edwinxxxx
                        wrote on 2 Aug 2019, 01:19 last edited by edwinxxxx 8 Feb 2019, 01:29
                        #33

                        @sgaist
                        platform: macos 10.14
                        mysql 8.0.17
                        qt 5.9.8

                        firstly i run

                        //otool -L libqsqlmysql.dylib
                        

                        but it shows

                        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: 'libqsqlmysql.dylib': No such file or directory
                        

                        how can i find the path like "opt/local..." on my machine?
                        thanks man.

                        J 1 Reply Last reply 2 Aug 2019, 04:15
                        0
                        • E edwinxxxx
                          2 Aug 2019, 01:19

                          @sgaist
                          platform: macos 10.14
                          mysql 8.0.17
                          qt 5.9.8

                          firstly i run

                          //otool -L libqsqlmysql.dylib
                          

                          but it shows

                          /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: 'libqsqlmysql.dylib': No such file or directory
                          

                          how can i find the path like "opt/local..." on my machine?
                          thanks man.

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 2 Aug 2019, 04:15 last edited by
                          #34

                          @edwinxxxx said in QMYSQL driver not loaded on mac:

                          how can i find the path like "opt/local..." on my machine?

                          find / -name libqsqlmysql.dylib
                          

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          E 1 Reply Last reply 2 Aug 2019, 06:07
                          0
                          • J jsulm
                            2 Aug 2019, 04:15

                            @edwinxxxx said in QMYSQL driver not loaded on mac:

                            how can i find the path like "opt/local..." on my machine?

                            find / -name libqsqlmysql.dylib
                            
                            E Offline
                            E Offline
                            edwinxxxx
                            wrote on 2 Aug 2019, 06:07 last edited by
                            #35

                            @jsulm sorry, i still cant find any folder whose name begin with "/opt/local..."

                            0_1564726030510_屏幕快照 2019-08-02 14.07.02.png

                            J 1 Reply Last reply 2 Aug 2019, 06:10
                            0
                            • E edwinxxxx
                              2 Aug 2019, 06:07

                              @jsulm sorry, i still cant find any folder whose name begin with "/opt/local..."

                              0_1564726030510_屏幕快照 2019-08-02 14.07.02.png

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 2 Aug 2019, 06:10 last edited by
                              #36

                              @edwinxxxx "/opt" is a system folder just under root /

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              E 1 Reply Last reply 2 Aug 2019, 06:20
                              0
                              • J jsulm
                                2 Aug 2019, 06:10

                                @edwinxxxx "/opt" is a system folder just under root /

                                E Offline
                                E Offline
                                edwinxxxx
                                wrote on 2 Aug 2019, 06:20 last edited by
                                #37

                                @jsulm is that mean i cant locate the file "libmysqlclient.xx.dylib" in my pc?

                                J 1 Reply Last reply 2 Aug 2019, 06:22
                                0
                                • E edwinxxxx
                                  2 Aug 2019, 06:20

                                  @jsulm is that mean i cant locate the file "libmysqlclient.xx.dylib" in my pc?

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 2 Aug 2019, 06:22 last edited by jsulm 8 Feb 2019, 06:23
                                  #38

                                  @edwinxxxx No, it doesn't mean that. If it is somewhere on your machine you can find it.
                                  Where did you install it?
                                  Did you try what I suggested?

                                  find / -name libmysqlclient.*.dylib
                                  

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  E 1 Reply Last reply 2 Aug 2019, 06:33
                                  0
                                  • J jsulm
                                    2 Aug 2019, 06:22

                                    @edwinxxxx No, it doesn't mean that. If it is somewhere on your machine you can find it.
                                    Where did you install it?
                                    Did you try what I suggested?

                                    find / -name libmysqlclient.*.dylib
                                    
                                    E Offline
                                    E Offline
                                    edwinxxxx
                                    wrote on 2 Aug 2019, 06:33 last edited by
                                    #39

                                    @jsulm Yes! it shows a lot of contents, and the related information is
                                    0_1564727625430_屏幕快照 2019-08-02 14.32.18.png

                                    J 1 Reply Last reply 2 Aug 2019, 06:37
                                    0
                                    • E edwinxxxx
                                      2 Aug 2019, 06:33

                                      @jsulm Yes! it shows a lot of contents, and the related information is
                                      0_1564727625430_屏幕快照 2019-08-02 14.32.18.png

                                      J Offline
                                      J Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on 2 Aug 2019, 06:37 last edited by
                                      #40

                                      @edwinxxxx So, it is in /usr/local, not /opt/local.

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0
                                      • E Offline
                                        E Offline
                                        edwinxxxx
                                        wrote on 2 Aug 2019, 06:45 last edited by edwinxxxx 8 Feb 2019, 06:48
                                        #41

                                        @jsulm when i call "otool -L " it indicates that

                                        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.8)
                                        	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.9.0, current version 5.9.8)
                                        	/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)
                                        	/usr/local/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
                                        	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
                                        	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
                                        

                                        so according to other's experience i run

                                        install_name_tool -change/usr/local/mysql/lib/libmysqlclient.20.dylib/usr/local/mysql-8.0.17-macos10.14-x86_64/lib/libmysqlclient.21.dylib/Users/edwinxxxx/Qt5.9.8/5.9.8/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                                        

                                        however,it seems didn't work still.

                                        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
                                        
                                        J 1 Reply Last reply 2 Aug 2019, 06:53
                                        0
                                        • E edwinxxxx
                                          2 Aug 2019, 06:45

                                          @jsulm when i call "otool -L " it indicates that

                                          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.8)
                                          	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.9.0, current version 5.9.8)
                                          	/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)
                                          	/usr/local/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
                                          	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
                                          	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
                                          

                                          so according to other's experience i run

                                          install_name_tool -change/usr/local/mysql/lib/libmysqlclient.20.dylib/usr/local/mysql-8.0.17-macos10.14-x86_64/lib/libmysqlclient.21.dylib/Users/edwinxxxx/Qt5.9.8/5.9.8/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                                          

                                          however,it seems didn't work still.

                                          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
                                          
                                          J Offline
                                          J Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on 2 Aug 2019, 06:53 last edited by
                                          #42

                                          @edwinxxxx said in QMYSQL driver not loaded on mac:

                                          install_name_tool -change/usr/local/mysql/lib/libmysqlclient.20.dylib/usr/local/mysql-8.0.17-macos10.14-x86_64/lib/libmysqlclient.21.dylib/Users/edwinxxxx/Qt5.9.8/5.9.8/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

                                          I'm really not an MacOS expert, but don't you miss spaces here? Everything adter -change is one string without any separation via spaces.

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          E 1 Reply Last reply 2 Aug 2019, 07:01
                                          1

                                          • Login

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