Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
7 Views

DLL dependency question

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
Highlighted
7 Views

1. Yes, it's possible to

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.

Retired 12/31/2016
0 Kudos
Beginner
7 Views

Thanks, Steve.  I will read

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
Highlighted
7 Views

If you're using the bundled

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

Retired 12/31/2016
0 Kudos
Highlighted
Beginner
7 Views

I've got retail VS2010, and

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