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. Connect to MYSQL failed in Qt

Connect to MYSQL failed in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt6c++mysqlmysql server
33 Posts 4 Posters 5.5k 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.
  • SGaistS SGaist

    Hi,

    Based on your .pro file content, you are not linking against the MySQL library.

    By the way, are you aware of the QtSql module ?

    E Offline
    E Offline
    ELEMENTICY
    wrote on last edited by
    #3

    @SGaist use qtsql get even more more and more error
    So its better use official sql library
    And yea,i copy the mysql include and lib folder to the project folder
    So thats why i use that

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @ELEMENTICY said in Connect to MYSQL failed in Qt:

      And yea,i copy the mysql include and lib folder to the project folder

      But you don't link against the mysql libs in your pro file.

      What does not work with the QtSql plugin?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      E 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @ELEMENTICY said in Connect to MYSQL failed in Qt:

        And yea,i copy the mysql include and lib folder to the project folder

        But you don't link against the mysql libs in your pro file.

        What does not work with the QtSql plugin?

        E Offline
        E Offline
        ELEMENTICY
        wrote on last edited by
        #5

        @Christian-Ehrlicher i do,

        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/libmysql
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/libmysqld
        else:unix: LIBS += -L$$PWD/lib/libmysql
        

        And yea,use qt sql it just give like 11 error
        And if i use official mysql mysql.h,it only give 2 error which is undefine

        And yea,or i need to change my profile's lib code to this?

        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/libmysql.lib
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/libmysqld.lib
        else:unix: LIBS += -L$$PWD/lib/libmysql.lib
        
        Christian EhrlicherC 1 Reply Last reply
        0
        • E Offline
          E Offline
          ELEMENTICY
          wrote on last edited by
          #6

          will it bcuz i use qt6+ so it doesnt work?(i mean qt sql)

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @ELEMENTICY said in Connect to MYSQL failed in Qt:

            it doesnt work

            This is no error description...

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            E 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @ELEMENTICY said in Connect to MYSQL failed in Qt:

              it doesnt work

              This is no error description...

              E Offline
              E Offline
              ELEMENTICY
              wrote on last edited by
              #8

              @Christian-Ehrlicher bcuz it give too much error,i rather use official mysql header
              Qt6 has alot of stuff doesnt exist.Like web browser
              So i rather use the official mysql header and it give less error

              These are the only error:
              error: undefined reference to 'mysql_init'

              error: undefined reference to 'mysql_real_connect'

              error: linker command failed with exit code 1 (use -v to see invocation) clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:73: libPos_x86_64.so] Error 1

              Use Qt sql give like 11 error or more/less

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

                The SQL module is supported in Qt 6. However the MySQL plugin might not be provided because Oracle changed their licensing.

                As for your build issue: -L is for giving path to search, it's -l for stating the name of the library.

                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
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  So the QtSql module has no errors - please stay specific!

                  else:unix: LIBS += -L$$PWD/lib/libmysql.lib

                  This is for sure not correct.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  E 2 Replies Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    So the QtSql module has no errors - please stay specific!

                    else:unix: LIBS += -L$$PWD/lib/libmysql.lib

                    This is for sure not correct.

                    E Offline
                    E Offline
                    ELEMENTICY
                    wrote on last edited by ELEMENTICY
                    #11

                    @Christian-Ehrlicher but qtsql mysql plugin doesnt provided as @SGaist said it,i tried add it by following youtube tutorial,it still doesnt.Lemme try it again and send the error here

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      So the QtSql module has no errors - please stay specific!

                      else:unix: LIBS += -L$$PWD/lib/libmysql.lib

                      This is for sure not correct.

                      E Offline
                      E Offline
                      ELEMENTICY
                      wrote on last edited by
                      #12

                      @Christian-Ehrlicher

                      This is for sure not correct.

                      oh,how do i fix it?

                      SGaistS 1 Reply Last reply
                      0
                      • E ELEMENTICY

                        @Christian-Ehrlicher

                        This is for sure not correct.

                        oh,how do i fix it?

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @ELEMENTICY said in Connect to MYSQL failed in Qt:

                        @Christian-Ehrlicher

                        This is for sure not correct.

                        oh,how do i fix it?

                        Re-read my previous answer.

                        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
                        0
                        • SGaistS SGaist

                          @ELEMENTICY said in Connect to MYSQL failed in Qt:

                          @Christian-Ehrlicher

                          This is for sure not correct.

                          oh,how do i fix it?

                          Re-read my previous answer.

                          E Offline
                          E Offline
                          ELEMENTICY
                          wrote on last edited by
                          #14

                          @SGaist so i have to make it

                          win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -l libmysql
                          else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -l libmysqld
                          else:unix: LIBS += -L$$PWD/lib/ -l libmysql
                          

                          ?

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

                            No space no "lib" prefix.

                            It's explained in the documentation

                            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
                            1
                            • SGaistS SGaist

                              No space no "lib" prefix.

                              It's explained in the documentation

                              E Offline
                              E Offline
                              ELEMENTICY
                              wrote on last edited by
                              #16

                              @SGaist my current profile code:

                              win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -llibmysql
                              else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -llibmysqld
                              else:unix: LIBS += -L$$PWD/lib/ -llibmysql
                              

                              documentation:

                              LIBS += -L"3rdparty/CatWhisperer/lib" -lCatWhisperer
                              

                              i got this error:
                              :-1: error: error: cannot find -llibmysql

                              proof that path exists:
                              Screenshot 2021-05-07 191143.png

                              SGaistS 1 Reply Last reply
                              0
                              • E ELEMENTICY

                                @Christian-Ehrlicher i do,

                                win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/libmysql
                                else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/libmysqld
                                else:unix: LIBS += -L$$PWD/lib/libmysql
                                

                                And yea,use qt sql it just give like 11 error
                                And if i use official mysql mysql.h,it only give 2 error which is undefine

                                And yea,or i need to change my profile's lib code to this?

                                win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/libmysql.lib
                                else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/libmysqld.lib
                                else:unix: LIBS += -L$$PWD/lib/libmysql.lib
                                
                                Christian EhrlicherC Offline
                                Christian EhrlicherC Offline
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #17

                                @ELEMENTICY said in Connect to MYSQL failed in Qt:

                                And yea,use qt sql it just give like 11 error

                                What does this mean?

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                1 Reply Last reply
                                0
                                • E ELEMENTICY

                                  @SGaist my current profile code:

                                  win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/ -llibmysql
                                  else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/ -llibmysqld
                                  else:unix: LIBS += -L$$PWD/lib/ -llibmysql
                                  

                                  documentation:

                                  LIBS += -L"3rdparty/CatWhisperer/lib" -lCatWhisperer
                                  

                                  i got this error:
                                  :-1: error: error: cannot find -llibmysql

                                  proof that path exists:
                                  Screenshot 2021-05-07 191143.png

                                  SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #18

                                  @ELEMENTICY did you read what I wrote ? No "lib" prefix.

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

                                  E 2 Replies Last reply
                                  0
                                  • SGaistS SGaist

                                    @ELEMENTICY did you read what I wrote ? No "lib" prefix.

                                    E Offline
                                    E Offline
                                    ELEMENTICY
                                    wrote on last edited by
                                    #19

                                    @SGaist
                                    current code:

                                    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/libmysql
                                    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/libmysqld
                                    else:unix: LIBS += -L$$PWD/lib/libmysql
                                    

                                    idk if i misunderstanded what u mean,but it still give error ;/
                                    or u mean i have to remove that -L

                                    SGaistS 1 Reply Last reply
                                    0
                                    • SGaistS SGaist

                                      @ELEMENTICY did you read what I wrote ? No "lib" prefix.

                                      E Offline
                                      E Offline
                                      ELEMENTICY
                                      wrote on last edited by
                                      #20

                                      @SGaist and yea i dont know if its because im working on a android app,so it doesnt work

                                      SGaistS 1 Reply Last reply
                                      0
                                      • E ELEMENTICY

                                        @SGaist
                                        current code:

                                        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/libmysql
                                        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/libmysqld
                                        else:unix: LIBS += -L$$PWD/lib/libmysql
                                        

                                        idk if i misunderstanded what u mean,but it still give error ;/
                                        or u mean i have to remove that -L

                                        SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #21

                                        @ELEMENTICY said in Connect to MYSQL failed in Qt:

                                        @SGaist
                                        current code:

                                        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/libmysql
                                        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/libmysqld
                                        else:unix: LIBS += -L$$PWD/lib/libmysql
                                        

                                        idk if i misunderstanded what u mean,but it still give error ;/
                                        or u mean i have to remove that -L

                                        You have to understand what -L and -l each do. I have already explained that before. So please re-read the corresponding answers.

                                        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
                                        • E ELEMENTICY

                                          @SGaist and yea i dont know if its because im working on a android app,so it doesnt work

                                          SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #22

                                          @ELEMENTICY said in Connect to MYSQL failed in Qt:

                                          @SGaist and yea i dont know if its because im working on a android app,so it doesnt work

                                          Oracle does not provide pre-built binaries for Android.

                                          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

                                          • Login

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