How to make a C++ program look for DLLs?

I want to be able to store DLLs in sub-folders without the EXE complaining about a missing DLL. How do I make the EXE look in a sub-folder, such as "DLLs"? If this has anything to do with it, my IDE is Code::Blocks.


To make this work with explicit loading (LoadLibrary/GetProcAddress) is easy enough. You are in control of the binding process and simply pass the full path to LoadLibrary.

For implicit loading you are at the mercy of the system. Whilst you could augment the PATH variable this is extremely draconian. Faced with the choice of putting all DLLs alongside the executable or modifying PATH, I would always choose the former.

There is also the option of DLL redirection but even Microsoft seem to advise you to place your DLLs alongside your executable rather than use redirection.

There are ways to do this via manifests or redirection, but these are pretty complicated.

I would recommend that instead, you use a structure as follows:


In the above example your real application is myapp_internal.exe, and it goes in the DLL sub-folder, so that all the DLLs can be located correctly. The myapp.exe binary is just a stub application that executes myapp_internal.exe.

I hope this helps!

Need Your Help

To CTE or not to CTE

sql-server performance common-table-expression maintainability

Having been stuck with SQL2000 for far too long, I've not really had a lot of exposure to Common Table Expressions.

Can i insert into two different tables from the same statement?

php mysql sql

i have a car application, so cars have a bunch of information avaible to count

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.