I have a visual studio solution with an exe and a DLL.
The code for the DLL has !DEC$ ATTRIBUTES DLLEXPORT statements
The code for the exe has !DEC$ ATTRIBUTES DLLIMPORT statements
If an attempt is made to run the exe without the DLL in the same folder, a message is displayed (by Windows, I think) that the DLL is missing. The message seems to appear before the exe begins to actually run.
When running cases when the exe doesn't need to call any routines in the DLL, is it possible for the exe to run without the DLL being present?
In a related question, is it possible to statically link a DLL to an exe? I ask this because I have a very old DLL that I have been unable to build with visual studio / Intel fortran (code is from ANSYS, I think). It is a very small DLL of about 30k, and I would prefer to link it statically and not have to haul it around with the exe.
1. Yes, it's possible to "delay load" the DLL so that it doesn't actually try to load until you call the routine. See https://msdn.microsoft.com/en-us/library/151kt790.aspx for more details. In particular you must link in delayimp.lib (this is one of the Windows support libraries provided) and then name the DLL in the /delayload linker option. No code changes are needed.
If you're using the bundled VS2010 Shell, you may not have delayimp.lib. If that's the case, you can either get it from the Windows SDK or update to the 2016 compiler with VS2013 Shell. I think we updated the shell installer in 2015U2 or thereabouts to fix this (MS had not included this in the files we could redistribute initially.)