Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue setting QLibrary path
Qt 6.12 LTS is out! See what's new in the release blog

Issue setting QLibrary path

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 3 Posters 3.5k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Since you have the library in the same folder as your executable, what do you get if you just use 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
    • T Offline
      T Offline
      Tiago M.Pinto
      wrote on last edited by
      #5

      In that case the app runs just fine. The problem is that I want to run the app from outside that folder but keeping the library there.

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

        Since you are using QCoreApplication::applicationFilePath, did you check that value ? I would expect it to be consistant with applicationDirPath but there might be surprises.

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

        T 1 Reply Last reply
        0
        • SGaistS SGaist

          Since you are using QCoreApplication::applicationFilePath, did you check that value ? I would expect it to be consistant with applicationDirPath but there might be surprises.

          T Offline
          T Offline
          Tiago M.Pinto
          wrote on last edited by
          #7

          @SGaist Yes, I checked applicationDirPath() and applicationFilePath() and they are consistent with each other. The issue seems to be somehow in the way QLibrary is interpreting the path.

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

            Do you get a canonical path ?

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

            T 1 Reply Last reply
            0
            • SGaistS SGaist

              Do you get a canonical path ?

              T Offline
              T Offline
              Tiago M.Pinto
              wrote on last edited by
              #9

              @SGaist What do you mean by "canonical"? I get absolute paths.

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

                It's an absolute path with all the .. and . resolved cleanly.

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

                T 1 Reply Last reply
                0
                • SGaistS SGaist

                  It's an absolute path with all the .. and . resolved cleanly.

                  T Offline
                  T Offline
                  Tiago M.Pinto
                  wrote on last edited by
                  #11

                  @SGaist yes, I get full absolute paths.

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

                    Just to be sure, you have that behaviour when calling your application form the command line ?

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

                    T 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Just to be sure, you have that behaviour when calling your application form the command line ?

                      T Offline
                      T Offline
                      Tiago M.Pinto
                      wrote on last edited by Tiago M.Pinto
                      #13

                      @SGaist this behaviour happens with applicationFilePath() in QtCreator and also when running from the command line outside the executable's directory. If I call it in the executable's directory, all works fine.

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

                        Can you provide a minimal compilable example that shows this behaviour ?

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

                        T 2 Replies Last reply
                        0
                        • SGaistS SGaist

                          Can you provide a minimal compilable example that shows this behaviour ?

                          T Offline
                          T Offline
                          Tiago M.Pinto
                          wrote on last edited by
                          #15

                          @SGaist I was setting up an example for you and I found out that it works as I intended. In the example I can now run the app from the command line with the executable and its library in another folder.

                          I have to investigate better what could be the issue in my application... I will be back here if I get new questions.
                          Thank you!

                          1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Can you provide a minimal compilable example that shows this behaviour ?

                            T Offline
                            T Offline
                            Tiago M.Pinto
                            wrote on last edited by
                            #16

                            @SGaist Just solved the problem. I forgot that I had another class loading the library where I didn't change the constructor in order to use applicationFilePath() with replace and split... my bad.
                            Thank you again!

                            Pablo J. RoginaP 1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #17

                              If you have several places like that, you might want to use a common base class to avoid that kind of situation.

                              Anyway, glad you found out and thanks for sharing !

                              Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

                              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
                              • T Tiago M.Pinto

                                @SGaist Just solved the problem. I forgot that I had another class loading the library where I didn't change the constructor in order to use applicationFilePath() with replace and split... my bad.
                                Thank you again!

                                Pablo J. RoginaP Offline
                                Pablo J. RoginaP Offline
                                Pablo J. Rogina
                                wrote on last edited by
                                #18

                                @Tiago-M-Pinto said in Issue setting QLibrary path:

                                Just solved the problem

                                so don't forget to mark your post as solved!

                                Upvote the answer(s) that helped you solve the issue
                                Use "Topic Tools" button to mark your post as Solved
                                Add screenshots via postimage.org
                                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                                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
                                • Unsolved