Question Regarding DLL Bundling

Here you can find everything you need to know about Dll-Files. You can also share your knowledge regarding the topic.

Moderators: DllAdmin, DLLADMIN ONLY

Post Reply
ulyssesmiller
Posts: 4
Joined: 23 Apr 2025, 04:49

Question Regarding DLL Bundling

Post by ulyssesmiller »

Hello everyone!

I have a quick inquiry about DLL file loading. I have an executable file, program.exe, that attempts to load the DLL libpq.dll from a specified directory. Is it possible to arrange it to load libpq.dll from the executable's directory instead?

Essentially, I want my Rust application to prioritize looking for essential DLLs in the executable's location. Here's how my project structure looks:

Copy Project Dir, Program.exe, and libpq.dll (<--). I want Program.exe to use this version rather than the one in the system directory.
Is it possible? Thanks in advance for your assistance!

ulyssesmiller
Posts: 4
Joined: 23 Apr 2025, 04:49

Re: Question Regarding DLL Bundling

Post by ulyssesmiller »

Does anyone have the answer?

fethiye
Posts: 1
Joined: 27 May 2025, 15:55

Re: Question Regarding DLL Bundling

Post by fethiye »

Solution: Load libpq.dll from the executable’s directory
On Windows, DLL search order is well-defined. By default, Windows searches in this order (simplified):

The directory where the executable is located

The system directory (e.g., C:\Windows\System32)

The Windows directory

The current working directory

The directories listed in the PATH environment variable

ulyssesmiller
Posts: 4
Joined: 23 Apr 2025, 04:49

Re: Question Regarding DLL Bundling

Post by ulyssesmiller »

ulyssesmiller wrote: 23 Apr 2025, 04:52 Hello everyone!

I have a quick inquiry about DLL file loading. I have an executable file, program.exe, that attempts to load the DLL libpq.dll from a specified directory. Is it possible to arrange it to load libpq.dll from the executable's directory instead?

Essentially, I want my Rust application to prioritize looking for essential DLLs in the executable's location. Here's how my project structure looks:
viewtopic.phpMonkey Mart
Copy Project Dir, Program.exe, and libpq.dll (<--). I want Program.exe to use this version rather than the one in the system directory.
Is it possible? Thanks in advance for your assistance!
Oh, I looked it up, Windows will actually load DLLs from the program's directory first, as long as the DLL is in the same directory as program.exe. If you want to be extra sure or have more control, you can use LoadLibrary with the full path in your code.

ulyssesmiller
Posts: 4
Joined: 23 Apr 2025, 04:49

Re: Question Regarding DLL Bundling

Post by ulyssesmiller »

Oh, I looked it up, Windows will actually load DLLs from the program's directory first, as long as the DLL is in the same directory as program.exe. If you want to be extra sure or have more control (Monkey Mart), you can use LoadLibrary with the full path in your code.

Post Reply