-1

I am making a win32 console app using msvc++ that is going to use a really simple dll. I put my .lib and header for my dll (my dll only has one header) into my console applications folder.

When I run it, I don't get any compile or linking errors, but when the app is actually open, it says it cant find the dll. When I put the .dll file into the console app's folder and run, it actually works. I would like to know why this happens??????

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
liuz
  • 1
  • 1
    Well, sure. An MSVC++ solution lets you create multiple projects. The executables all end up in the same place, the solution's Debug directory by default. If you don't use that feature then you'll have to copy files yourself. Use the feature. – Hans Passant Sep 04 '15 at 23:04

1 Answers1

0

Look at this link:

Dynamic-Link Library Search Order

Windows has a DLL search order. You can change it by functions specified in the above link.

Your import library is used to define information about functions in your DLL and so. You can use LoadLibrary("myDLL.dll") function to load DLL without header.

In this case you must use GetProcAddress(module, "function_name") function to get function adresses in your DLL.

GetProcAddress function

and here is the link where is some solution for GetProcAddress():

Calling functions in a DLL from C++

Community
  • 1
  • 1
Cruppy
  • 54
  • 4
  • 1
    The issue is the DLL search order. The rest of your answer has nothing to do with the question that liuz asked. `LoadLibrary()`/`GetProcAddress()` is not the answer to this problem, though it is an alternative solution if you want to load the DLL from a location that is not included in the DLL search order (though you could use `SetDllDirectory()` or `AddDllDirectory()` to address that). – Remy Lebeau Sep 05 '15 at 00:07