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. ld: library not found for -lmysqlclient_r (when trying to build mysql driver on mac)
Forum Updated to NodeBB v4.3 + New Features

ld: library not found for -lmysqlclient_r (when trying to build mysql driver on mac)

Scheduled Pinned Locked Moved Solved Installation and Deployment
22 Posts 2 Posters 11.9k 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.
  • L Offline
    L Offline
    LeeH
    wrote on last edited by
    #6

    This is what I downloaded (if it helps)

    server 5.7.18 mac os dmg archive
    workbench 6.3.9 mac os dmg archive

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

      Then replace -lmysqlclient_r with -lmysqlclient.

      The _r means re-entrant but AFAIK, the latest versions of the client libraries should be re-entrant anyway.

      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
      • L Offline
        L Offline
        LeeH
        wrote on last edited by
        #8

        I just tried that, and no luck gave the same error for '-lmysqlclient' :(

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

          You still need to give the linker the path where to find the librairies.

          Add

          LIBS += -L/path/to/MySQL_libs/
          

          to your .pro file.

          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
          • L Offline
            L Offline
            LeeH
            wrote on last edited by
            #10
            This post is deleted!
            1 Reply Last reply
            0
            • L Offline
              L Offline
              LeeH
              wrote on last edited by
              #11

              Hi sorry to be a pain, still not worked yet... If I've understood you I tried:

              adding path to lib 'LIBS += -L/usr/local/mysql/lib' to my mysql.pro:

              TARGET = qsqlmysql
              
              LIBS += -L/usr/local/mysql/lib     <---
              
              HEADERS += $$PWD/qsql_mysql_p.h
              SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
              
              QMAKE_USE += mysql
              
              OTHER_FILES += mysql.json
              
              PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
              include(../qsqldriverbase.pri)
              

              then run qmake cmd with '-lmysqlclient'

              qmake "INCLUDEPATH+=/usr/local/mysql/include" "LIBS+=-L/usr/local/lib -lmysqlclient" mysql.pro
              

              make

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

                What exact error do you get this time ?

                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
                • L Offline
                  L Offline
                  LeeH
                  wrote on last edited by
                  #13

                  Now that you mentioned the error, I can see that it's still refering to '-lmysqlclient_r' even though I ran '-lmysqlclient'. I wonder what thats about? Here it is:

                  Last login: Sat May 27 23:01:02 on console
                  Leons-Mac:~ ldigital$ cd Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql
                  Leons-Mac:mysql ldigital$ qmake "INCLUDEPATH+=/usr/local/mysql/include" "LIBS+=-L/usr/local/lib -lmysqlclient" mysql.pro
                  Leons-Mac:mysql ldigital$ make
                  /Applications/Xcode.app/Contents/Developer/usr/bin/make -f  Makefile.Release all
                  rm -f libqsqlmysql.dylib
                  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9  -Wl,-rpath,@loader_path/../../lib -single_module -dynamiclib -o libqsqlmysql.dylib .obj/release/qsql_mysql.o .obj/release/main.o .obj/release/moc_qsql_mysql_p.o  -F/Users/ldigital/Qt/5.8/clang_64/lib -L/usr/local/lib -lmysqlclient -L/usr/local/mysql/lib -framework QtSql -framework QtCore -framework DiskArbitration -framework IOKit -L/opt/local/lib/mysql55/mysql -lmysqlclient_r -lz  
                  ld: warning: directory not found for option '-L/opt/local/lib/mysql55/mysql'
                  ld: library not found for -lmysqlclient_r
                  clang: error: linker command failed with exit code 1 (use -v to see invocation)
                  make[1]: *** [../../../../plugins/sqldrivers/libqsqlmysql.dylib] Error 1
                  make: *** [release-all] Error 2
                  
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    Edit /qtbase/src/sql/configure.json and change the library name.

                    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
                    • L Offline
                      L Offline
                      LeeH
                      wrote on last edited by
                      #15

                      ok here is the libraries section for mysql in configure.json:

                       "mysql": {
                              "label": "MySQL",
                              "test": "unix/mysql",
                              "sources": [
                                  { "type": "mysqlConfig", "query": "--libs_r" },
                                  { "type": "mysqlConfig", "query": "--libs" },
                                  { "libs": "-lmysqlclient_r", "condition": "!config.win32" },
                                  { "libs": "-llibmysql", "condition": "config.win32" },
                                  { "libs": "-lmysqlclient", "condition": "!config.win32" }
                              ]
                          },
                      

                      I removed (temporarily) the '-libmysqlclient_r' line seeing as '-libmysqlclient' is already there, and tried again but still gives the same error for -lmysqlclient_r

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

                        Don't remove it, updated it, see the condition part.

                        You should also cleanup your build folder and try to build from scratch.

                        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
                        • L Offline
                          L Offline
                          LeeH
                          wrote on last edited by
                          #17

                          ok do you mean:

                           { "libs": "-lmysqlclient_r", "condition": "-lmysqlclient" },   ?
                          

                          because I have no idea whats going on here tbh

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

                            I meant: just remove the _r. The condition basically states that this line apply all configurations that are not win32.

                            Note that I missed the one further down. So in fact, removing it was a correct solution, sorry for the confusion.

                            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
                            • L Offline
                              L Offline
                              LeeH
                              wrote on last edited by
                              #19

                              That's ok. Is there anything else I can try? this is really stressing me out, and I am still searching the web for other solutions... one is homebrew but I don't know if I should or not. What do you think?

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

                                Personally I usually use macports which is a homebrew equivalent to get my dependencies on macOS but both are 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
                                1
                                • L Offline
                                  L Offline
                                  LeeH
                                  wrote on last edited by LeeH
                                  #21

                                  Thanks for that. I shall leave you in peace for a while as I explore them and see how things turn out, and thanks so much for your help so far. I really appreciate it.

                                  1 Reply Last reply
                                  0
                                  • L Offline
                                    L Offline
                                    LeeH
                                    wrote on last edited by LeeH
                                    #22

                                    YEEAAH!

                                    After another 2 days of battling, I FINALLY got it working. I had totally given up on the conventional method of doing this for mac, as it was getting me no where. I still cannot for the life of me understand why Qt didn't load this very popular driver in the release and why building this driver on mac is so difficult when I had previously got it working on windows the conventional way much easier (thanks to @SGaist and others).

                                    Anyway Homebrew worked by installing Qt and MySql together: (this takes a very long time)

                                    brew install qt5 --with-mysql
                                    

                                    after that installed Qt creator:

                                    brew cask install qt-creator
                                    

                                    then configured MySql as normal through terminal as it seems you can't get sysprefpane this way.

                                    Hopefully this can help others, and a big thanks to @SGaist for taking the time!

                                    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