I am playing with DLLs to get a better understanding of them. So I created a simple dll (with load-time dynamic linking) which has functions to Add
, Sub
and Mul
. In the header file for the dll I used __declspec(dllexport)
for the function declaration.
For the executable, I added the .lib created after compiling the dll to the properties (for linking). After that I directly called the function Add
without using __declspec(dllimport)
. The program worked. I then changed the function calling to __declspec(dllimport) (Add)
and the program worked again.
I am not able to understand what the need of __declspec(dllimport)
is? I have not yet coded a run-time linking DLL but from the examples I have seen, dllimport is not needed in that case as well.
Thanks for your assistance.