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. QMYSQL working on Windows and Mac but not Android
Forum Update on Monday, May 27th 2025

QMYSQL working on Windows and Mac but not Android

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
21 Posts 4 Posters 6.3k 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.
  • L Offline
    L Offline
    LeeH
    wrote on 4 Jul 2017, 07:40 last edited by
    #1

    Hi, I have the QMYSQL driver working fine for Windows and Mac, but as soon as I deploy to the same app to Android from windows I get this error:

    W         : (null):0 ((null)): QSqlDatabase: QMYSQL driver not loaded
    W         : (null):0 ((null)): QSqlDatabase: available drivers: QSQLITE
    W         : (null):0 ((null)): QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
    

    contents of my qtbase/plugins/sqldrivers :

    libqsqlmysql.a
    libqsqlmysqld.a
    qsqlmysql.dll
    qsqlmysqld.dll
    

    This only happened after a recent fresh install of windows everything was fine before. Thanks for any help.

    Windows 10 pro
    Qt 5.9
    minGW32
    android armv7

    R 1 Reply Last reply 4 Jul 2017, 07:53
    0
    • L LeeH
      4 Jul 2017, 07:40

      Hi, I have the QMYSQL driver working fine for Windows and Mac, but as soon as I deploy to the same app to Android from windows I get this error:

      W         : (null):0 ((null)): QSqlDatabase: QMYSQL driver not loaded
      W         : (null):0 ((null)): QSqlDatabase: available drivers: QSQLITE
      W         : (null):0 ((null)): QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
      

      contents of my qtbase/plugins/sqldrivers :

      libqsqlmysql.a
      libqsqlmysqld.a
      qsqlmysql.dll
      qsqlmysqld.dll
      

      This only happened after a recent fresh install of windows everything was fine before. Thanks for any help.

      Windows 10 pro
      Qt 5.9
      minGW32
      android armv7

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 4 Jul 2017, 07:53 last edited by
      #2

      @LeeH
      you can use qputenv("QT_DEBUG_PLUGINS", "1") before creating a QApplication instance and check the output. It might give some hints what is failing.

      IIRC the mysql plugin also links against mysql lib. So did you also deploy this one?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      L 1 Reply Last reply 4 Jul 2017, 12:25
      1
      • L Offline
        L Offline
        LeeH
        wrote on 4 Jul 2017, 08:15 last edited by
        #3

        @raven-worx Hi, thanks for quick response I will use qputenv("QT_DEBUG_PLUGINS", "1") and see what i get. Tbh not sure what you mean here: "IIRC the mysql plugin also links against mysql lib. So did you also deploy this one?"

        J 1 Reply Last reply 4 Jul 2017, 08:28
        0
        • L LeeH
          4 Jul 2017, 08:15

          @raven-worx Hi, thanks for quick response I will use qputenv("QT_DEBUG_PLUGINS", "1") and see what i get. Tbh not sure what you mean here: "IIRC the mysql plugin also links against mysql lib. So did you also deploy this one?"

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 4 Jul 2017, 08:28 last edited by
          #4

          @LeeH You need libmysql.so on your device as well, that is what @raven-worx means.

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

          1 Reply Last reply
          1
          • L Offline
            L Offline
            LeeH
            wrote on 4 Jul 2017, 08:53 last edited by
            #5

            @jsulm Hi, I am new to this area of Qt lol... so I did a search for 'libmysql.so' but only have 'libmysql.dll' and 'libmysql.lib' on my computer. Is this missing file the reason??? I do not recall needing it before... i dunno

            J 1 Reply Last reply 4 Jul 2017, 08:57
            0
            • L LeeH
              4 Jul 2017, 08:53

              @jsulm Hi, I am new to this area of Qt lol... so I did a search for 'libmysql.so' but only have 'libmysql.dll' and 'libmysql.lib' on my computer. Is this missing file the reason??? I do not recall needing it before... i dunno

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 4 Jul 2017, 08:57 last edited by
              #6

              @LeeH You always need it - it is the actual interface to MySQL and is used by Qt MySQL plug-in.
              'libmysql.dll' and 'libmysql.lib' - this is for Windows, you need one for Android.

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

              L 1 Reply Last reply 4 Jul 2017, 09:02
              1
              • J jsulm
                4 Jul 2017, 08:57

                @LeeH You always need it - it is the actual interface to MySQL and is used by Qt MySQL plug-in.
                'libmysql.dll' and 'libmysql.lib' - this is for Windows, you need one for Android.

                L Offline
                L Offline
                LeeH
                wrote on 4 Jul 2017, 09:02 last edited by
                #7

                @jsulm ah ok, so could you please tell me how to get it? What I don't understand is why it all worked on my previous installation, and why/where things have gone wrong here...

                J 1 Reply Last reply 4 Jul 2017, 09:06
                0
                • L LeeH
                  4 Jul 2017, 09:02

                  @jsulm ah ok, so could you please tell me how to get it? What I don't understand is why it all worked on my previous installation, and why/where things have gone wrong here...

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 4 Jul 2017, 09:06 last edited by
                  #8

                  @LeeH The correct name is actually libmysqlclient.so, I don't know why it worked for you before.
                  Maybe this can help: https://wiki.qt.io/Build_Qt_5_MySQL_Plugin_for_Android

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

                  L 1 Reply Last reply 4 Jul 2017, 10:13
                  1
                  • J jsulm
                    4 Jul 2017, 09:06

                    @LeeH The correct name is actually libmysqlclient.so, I don't know why it worked for you before.
                    Maybe this can help: https://wiki.qt.io/Build_Qt_5_MySQL_Plugin_for_Android

                    L Offline
                    L Offline
                    LeeH
                    wrote on 4 Jul 2017, 10:13 last edited by
                    #9

                    @jsulm thanks for that post but I had seen that page way back when I first had problems building the mysql driver on windows. It didn't make sense to me then, and it doesn't now tbh, but I did get it to work perfectly without that. Maybe I should reinstall the android sdk's? It seems like its just a deployment to android issue, but I am open to any new suggestions... cheers

                    1 Reply Last reply
                    0
                    • R raven-worx
                      4 Jul 2017, 07:53

                      @LeeH
                      you can use qputenv("QT_DEBUG_PLUGINS", "1") before creating a QApplication instance and check the output. It might give some hints what is failing.

                      IIRC the mysql plugin also links against mysql lib. So did you also deploy this one?

                      L Offline
                      L Offline
                      LeeH
                      wrote on 4 Jul 2017, 12:25 last edited by LeeH 7 Apr 2017, 12:26
                      #10

                      @raven-worx Hi, I put:

                      qDebug() << qputenv("QT_DEBUG_PLUGINS", "1"); 
                      QApplication app(argc, argv);
                      

                      and in the android log it return 'true'

                      ...
                      D         : ..\test\main.cpp:31 (int main(int, char**)): true
                      ...
                      

                      Is this what you meant? Is it doing what it's supposed to? Did I make a mistake?
                      '

                      R 1 Reply Last reply 4 Jul 2017, 13:00
                      0
                      • L LeeH
                        4 Jul 2017, 12:25

                        @raven-worx Hi, I put:

                        qDebug() << qputenv("QT_DEBUG_PLUGINS", "1"); 
                        QApplication app(argc, argv);
                        

                        and in the android log it return 'true'

                        ...
                        D         : ..\test\main.cpp:31 (int main(int, char**)): true
                        ...
                        

                        Is this what you meant? Is it doing what it's supposed to? Did I make a mistake?
                        '

                        R Offline
                        R Offline
                        raven-worx
                        Moderators
                        wrote on 4 Jul 2017, 13:00 last edited by raven-worx 7 Apr 2017, 13:00
                        #11

                        @LeeH said in QMYSQL working on Windows and Mac but not Android:

                        Is this what you meant?

                        no, not what this command returns.
                        With this env variable set Qt should print some debug info of the plugin loading process.

                        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                        If you have a question please use the forum so others can benefit from the solution in the future

                        L 1 Reply Last reply 4 Jul 2017, 13:12
                        0
                        • R raven-worx
                          4 Jul 2017, 13:00

                          @LeeH said in QMYSQL working on Windows and Mac but not Android:

                          Is this what you meant?

                          no, not what this command returns.
                          With this env variable set Qt should print some debug info of the plugin loading process.

                          L Offline
                          L Offline
                          LeeH
                          wrote on 4 Jul 2017, 13:12 last edited by
                          #12

                          @raven-worx ok - but there is a lot of information here, and I don't know what I'm looking for, I can't see anything about debug for plugins.

                          1 Reply Last reply
                          0
                          • L Offline
                            L Offline
                            LeeH
                            wrote on 5 Jul 2017, 16:39 last edited by
                            #13

                            @raven-worx Hi, I think I've managed to find the additional info that 'qputenv("QT_DEBUG_PLUGINS", "1");' provides. I hope it's what you meant but here it is:

                            W libtest.so: (null):0 ((null)): Found metadata in lib /data/data/org.qtproject.example.test/qt-reserved-files/plugins/sqldrivers/libqsqlite.so, metadata=
                            W libtest.so: {
                            W libtest.so:     "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                            W libtest.so:     "MetaData": {
                            W libtest.so:         "Keys": [
                            W libtest.so:             "QSQLITE"
                            W libtest.so:         ]
                            W libtest.so:     },
                            W libtest.so:     "className": "QSQLiteDriverPlugin",
                            W libtest.so:     "debug": false,
                            W libtest.so:     "version": 329985
                            W libtest.so: }
                            

                            Thanks

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 5 Jul 2017, 21:13 last edited by
                              #14

                              Hi,

                              It confirms that only the SQLite plugin is available for android.

                              IIRC, you can now find more information about how to use QtWidget and custom plugins altogether.

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

                              L 1 Reply Last reply 6 Jul 2017, 11:27
                              0
                              • SGaistS SGaist
                                5 Jul 2017, 21:13

                                Hi,

                                It confirms that only the SQLite plugin is available for android.

                                IIRC, you can now find more information about how to use QtWidget and custom plugins altogether.

                                L Offline
                                L Offline
                                LeeH
                                wrote on 6 Jul 2017, 11:27 last edited by
                                #15

                                @SGaist Hi, thanks for your reply. I am really stuck and confused here because as I mentioned in earlier post I did not need to build the android driver seperately before, I just installed mysql software from their site and loaded the windows mysql driver and mysql worked from windows and android perfectly, Might sound silly but I've tried uninstalling and reinstalling mysql community software in a hope to try to replicate what I did before. but no luck. If I do need to build it manually this time, then the info here: https://wiki.qt.io/Build_Qt_5_MySQL_Plugin_for_Android (I assume I need option 3) but is even more confusing at this moment because option 3 appears to be incomplete. What can I do? Thanks.

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 6 Jul 2017, 20:56 last edited by
                                  #16

                                  Then please, show that earlier version that worked. Oracle doesn't provide any official driver for Android otherwise the Qt SDK would be offered with that plugin already built.

                                  Option 3 is not incomplete, it's not there as it's written it's a stub.

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

                                  L 1 Reply Last reply 6 Jul 2017, 21:21
                                  0
                                  • SGaistS SGaist
                                    6 Jul 2017, 20:56

                                    Then please, show that earlier version that worked. Oracle doesn't provide any official driver for Android otherwise the Qt SDK would be offered with that plugin already built.

                                    Option 3 is not incomplete, it's not there as it's written it's a stub.

                                    L Offline
                                    L Offline
                                    LeeH
                                    wrote on 6 Jul 2017, 21:21 last edited by LeeH 7 Jun 2017, 21:25
                                    #17

                                    @SGaist Hi again, sorry not earlier version of mysql server community software as that was and is 5.7. I meant Qt version 5.8 is when everything just worked, so Ive been back and forth between Qt 5.8 and 5.9.1. However when I have returned to Qt 5.8 android dosen't build at all, there are no sdk's available in my android build apk area even though they are installed. I also have sdk tools 25.2.5. But in Qt 5.9.1 These problems don't exist and android builds fine, but complains about the mysql driver... I'm loosing my mind!

                                    1 Reply Last reply
                                    0
                                    • L Offline
                                      L Offline
                                      LeeH
                                      wrote on 7 Jul 2017, 15:32 last edited by
                                      #18

                                      I think I know where I messed up. I'm not sure, but I need to sort it out when I get more time... Thanks to you all for your help so far. Hopefully I should get this sorted.

                                      1 Reply Last reply
                                      0
                                      • L Offline
                                        L Offline
                                        LeeH
                                        wrote on 11 Jul 2017, 09:53 last edited by
                                        #19

                                        I thought I did something wrong but after correcting that it didn't make a difference... Anyway I have accepted that how it worked before is gone , so I need to build it myself. I have now got MSYS installed and that appears to work:

                                        MSYS 1.0.11
                                        MSYS DTK 1.0
                                        MSYS Core 1.0.11

                                        I am now trying to work through option 2 https://wiki.qt.io/Build_Qt_5_MySQL_Plugin_for_Android. Before running the script, I edit these lines:

                                        from

                                        output_dir="libmariadb_so_output"
                                        build_dir="build_libmariadb_temp"
                                        
                                        export ANDROID_NDK_ROOT="/d/SDKs/Android/ndk-bundle"
                                        export QT_ROOT="/d/SDKs/Qt/5.7"
                                        
                                        SR="$ANDROID_NDK_ROOT/platforms/android-17/arch-arm/"
                                        BR="$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi- 4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-"
                                        

                                        to

                                        output_dir="/c/android_output"
                                        build_dir="build_libmariadb_temp"
                                        
                                        export ANDROID_NDK_ROOT="/c/android-ndk-r15b"
                                        export QT_ROOT="/c/Qt/5.9"
                                        
                                        SR="$ANDROID_NDK_ROOT/platforms/android-21/arch-arm"
                                        BR="$ANDROID_NDK_ROOT/toolchains/aarch64-linux-android-4.9/prebuilt/windows/bin/aarch64-linux-android-gcc-4.9"
                                        

                                        I leave everything else as it is then run the script. At the end I get:

                                        sh: !": event not found
                                        

                                        Then check in the output directory I set for the .so file and file is not there. I have never used MSYS before, I'm just trying to follow steps on wiki page option 2... thanks

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on 11 Jul 2017, 11:36 last edited by
                                          #20

                                          Like I already wrote, no Qt release was provided with MySQL driver for Android since there's no official client library for that platform.

                                          As for the error you got, it seems related to the sh interpreter, you should look up for that.

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

                                          L 1 Reply Last reply 11 Jul 2017, 15:01
                                          0

                                          1/21

                                          4 Jul 2017, 07:40

                                          • Login

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