Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Building QT with "windeployqt": not connect to database (ODBC)

    Installation and Deployment
    database odbc windeployqt build
    4
    24
    1222
    Loading More Posts
    • 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.
    • A
      AndreaCT last edited by

      Hello, and sorry for my not perfect English.

      I developed a simple UI application with QT, connected to a local database (using XAMPP). I downloaded the ODBC connector (https://dev.mysql.com/downloads/connector/odbc) and configured the connection to the database through ODBC Data Sources. In the main I connect to the database and everything works correctly.

      Then I generated the executable of my project and related dependencies using the windeployqt command from terminal. I put all in the same folder and the executable works perfectly.

      Then I moved everything (exe + dependencies) to another PC (with the same database locally and xampp running), but here the connection to the database fails.

      How can I solve it? Thanks!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Did you check that you also deployed the connector's dll and its dependencies along with your application ?

        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 Reply Quote 0
        • A
          AndreaCT last edited by

          That's all! Into sqldrivers there is qsqlodbc.dll

          aed36cf9-821e-46a5-ad84-9ba6f62bf267-image.png

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Use a tool like Dependency Walker to find the direct dependencies you need to deploy.

            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 Reply Quote 0
            • A
              AndreaCT last edited by

              Mmh this is the output:

              859ec731-b1c2-4409-b553-1fda4451e4b1-image.png

              How can recognize and integrate the direct dependencies?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                This is for your application executable, you should check the database plugin.

                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 Reply Quote 0
                • A
                  AndreaCT last edited by

                  Mmh so I don't have to open my exe in dependency walker?
                  Sorry and thank you for your patience...

                  1 Reply Last reply Reply Quote 0
                  • A
                    AndreaCT last edited by

                    C:\Qt\5.14.2\mingw73_32\plugins\sqldrivers\qsqlodbc.dll
                    I have to run dependency walker on it, right?

                    1 Reply Last reply Reply Quote 0
                    • A
                      AndreaCT last edited by

                      Eventually, this is the output:

                      3d776aa1-95bd-4e70-a895-b5eb28b92d2b-image.png

                      These are already present:

                      • LIBGCC_S_DW2-1.DLL
                      • LIBSTDC++-6.DLL
                      • QT5CORE.DLL
                      • QT5SQL.DLL

                      I downloaded the other 3 [https://www.dll-files.com/search.dll.html], and added these in the same folder.

                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        And the ODBC dll ?

                        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 Reply Quote 0
                        • A
                          AndreaCT last edited by

                          ODBC32.dll, no?

                          1 Reply Last reply Reply Quote 0
                          • SGaist
                            SGaist Lifetime Qt Champion last edited by

                            Yes, did you check the dependencies of that one ?

                            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 Reply Quote 0
                            • A
                              AndreaCT last edited by

                              53b13833-e676-4a7d-ba28-64abf8e93832-image.png

                              Download and put inside all the missing dll?

                              1 Reply Last reply Reply Quote 0
                              • A
                                AndreaCT last edited by

                                Unfortunately the problem persists

                                1 Reply Last reply Reply Quote 0
                                • hskoglund
                                  hskoglund last edited by

                                  Hi, just guessing, are you using 127.0.0.1 (or localhost) to connect to the database also on the new PC? Also, have you checked that you can reach the database with MySQL workbench?

                                  1 Reply Last reply Reply Quote 0
                                  • A
                                    AndreaCT last edited by

                                    Yes to both

                                    1 Reply Last reply Reply Quote 0
                                    • hskoglund
                                      hskoglund last edited by

                                      Ok. Is it same version of Windows 10 on both computers?

                                      A 1 Reply Last reply Reply Quote 0
                                      • J
                                        JSher last edited by

                                        Is the ODCB connection created on 2nd computer? Also with mysql connector you need Visual C++2015 distro.

                                        --James

                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          AndreaCT @hskoglund last edited by

                                          @hskoglund Yes

                                          1 Reply Last reply Reply Quote 0
                                          • A
                                            AndreaCT last edited by

                                            @JSher No, I just tried to print the error on a label with db.lastError() and the output is: "[Microsoft][Driver Manager ODBC] Nome origine dati non trovato e driver predefinito non specificato. QODBC3: Unable to connect"

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post