Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

DLL dependency question

Brian_Murphy
New Contributor II
322 Views

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.

Thanks,

Brian

0 Kudos
4 Replies
Steven_L_Intel1
Employee
322 Views

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.

2. No.

0 Kudos
Brian_Murphy
New Contributor II
322 Views

Thanks, Steve.  I will read through the stuff at those links.  If it's not over my head, it looks like it will do exactly what I asked.

Brian

0 Kudos
Steven_L_Intel1
Employee
322 Views

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.)

0 Kudos
Brian_Murphy
New Contributor II
322 Views

I've got retail VS2010, and there is delayimp.lib in the visual studio 10.0\VC\lib folder.  So I should have what is needed.

Thanks

Brian

0 Kudos
Reply