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. How to set the dll path of the main program
Forum Updated to NodeBB v4.3 + New Features

How to set the dll path of the main program

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 1.3k 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by nicker player
    #1

    My program depends on some third party dlls(not the qt plugins).
    So how to make the relative path of the main program to put the dlls.
    I only know the method of set PATH on windows.Are there any other solutions to solve this problem?
    here's the structure of the program

    ./main.exe
    ./bin/dllfiles1/third_party1.dll
    ./bin/dllfiles2/third_party2.dll
    ./other_source_files
    
    jsulmJ 1 Reply Last reply
    0
    • Ronel_qtmasterR Offline
      Ronel_qtmasterR Offline
      Ronel_qtmaster
      wrote on last edited by
      #2

      simply put the dll files in the same folder of your exe file

      nicker playerN 1 Reply Last reply
      1
      • nicker playerN nicker player

        My program depends on some third party dlls(not the qt plugins).
        So how to make the relative path of the main program to put the dlls.
        I only know the method of set PATH on windows.Are there any other solutions to solve this problem?
        here's the structure of the program

        ./main.exe
        ./bin/dllfiles1/third_party1.dll
        ./bin/dllfiles2/third_party2.dll
        ./other_source_files
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @nicker-player You can use https://doc.qt.io/qt-6/qt-conf.html

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

        1 Reply Last reply
        0
        • Ronel_qtmasterR Ronel_qtmaster

          simply put the dll files in the same folder of your exe file

          nicker playerN Offline
          nicker playerN Offline
          nicker player
          wrote on last edited by nicker player
          #4

          @Ronel_qtmaster
          I need to put the sub path of the exe file root.In fact,if i do that, the exe wont work cause couldnt find the dll files.

          @jsulm
          I think the qt.conf couldnt solve my problem.because I need to put the dlls in different sub folders of the exe file.And the qt.conf seemed not working on that.

          1 Reply Last reply
          0
          • Chris KawaC Online
            Chris KawaC Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            The search order for load time DLLs is documented and doesn't allow for additional search paths. You can alter the PATH variable or the registry key for known locations, but both of these are highly discouraged. You should not modify user's system just for your app. The standard and most common way to do it is deploying your app with all the dependent DLLs in the same directory as the executable. I would suggest to setup your build system to create a structure like that.

            Only runtime DLLs, like plugins or libraries loaded dynamically via QLibrary or directly with WinAPI LoadLibrary can have their search paths altered. For Qt plugins you do that with qt.conf file and for other libraries you can use SetDllDirectory.

            C 1 Reply Last reply
            2
            • Chris KawaC Chris Kawa

              The search order for load time DLLs is documented and doesn't allow for additional search paths. You can alter the PATH variable or the registry key for known locations, but both of these are highly discouraged. You should not modify user's system just for your app. The standard and most common way to do it is deploying your app with all the dependent DLLs in the same directory as the executable. I would suggest to setup your build system to create a structure like that.

              Only runtime DLLs, like plugins or libraries loaded dynamically via QLibrary or directly with WinAPI LoadLibrary can have their search paths altered. For Qt plugins you do that with qt.conf file and for other libraries you can use SetDllDirectory.

              C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              It should also be possible to use Windows application and DLL manifest entries to achieve DLL redirection during program start. This is a dark art AFAICT.

              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