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

question on DelayLoad of DLLs

forall
Beginner
757 Views

Hi,

I am trying to make sense of delay-loading of DLLs, and whether it can be applied to my problem.

I have written a (Fortran) code, compiled/built into an EXE. For users who have Matlab on their machines, I am able to provide (optional) additional functionality using Matlab DLLs. This optional functionality is nice but non-essential, and is not used unless the user explicitly requests it.

When I look at the dependencies of my EXE (eg, using Dependency Walker), I see that it requires the Matlab DLLs (as expected). Therefore, on a machine with no Matlab, the EXE returns an error due to missing DLLs.

What I wanted to do, is to specify the Matlab DLLs to be delay-loaded, with the intention that users without Matlab can use the same EXE file (but without invoking its Matlab-based functions). This would cut down the number of EXE versions I have, making it more manageable.

For this, I pasted the DLL names into the DelayLoad list given in the Project Settings, and added "delayimp.lib" as per the help instructions. However, while the linker worked, it also gave a message that there are no dependencies on these DLLS and that the delayLoad will ignore them. But, when I try to run the EXE on a machine with no DLLs, it immediately complains.

Is there a reason why the Delay DLL doesnt work here?

A specificity of my EXE file is that it does not access the DLLs itself, but rather through Matlab-provided code, linked against via static libraries. Could it be that the linker sees no *direct* dependencies of the compiled code on the Matlab DLLs and hence ignores the delayLoad instruction? And if so, is there a way to force this?

many thanks,

Dmitri

Hi,

I am trying to make sense of delay-loading of DLLs, and whether it can be applied to my

problem.

I have written a (Fortran) code, compiled/built into an EXE. For users who have Matlab

on their machines, I am able to provide (optional) additional functionality using Matlab

DLLs. This optional functionality is nice but non-essential, and would not be used

unless the user explicitly requests them.

When I look at the dependencies of my EXE (eg, using Dependency Walker), I see that it

requires the Matlab DLLs (as expected). Therefore, on a machine with no Matlab, the EXE

returns an error due to missing DLLs.

What I wanted to do, is to specify the Matlab DLLs to be delay-loaded, with the

intention that users without Matlab can use the same EXE file (but without invoking its

Matlab-based functions).

For this, I pasted the DLL names into the DelayLoad list given in the Project Settings, and added

"delayimp.lib" as per the help instructions. However, while the linker worked, it also

gave a message that there are no dependencies on these DLLS and that the delayLoad will

ignore them. But, when I try to run the EXE on a machine with no DLLs, it immediately

complains.

Is there a reason why the Delay DLL doesnt work here?

A specificity of my EXE file is that it does not access the DLLs itself, but rather

through Matlab-provided code, linked against via static libraries. Could it be that the

linker sees no *direct* dependencies of the compiled code on the Matlab DLLs and hence

ignores the delayLoad instruction? And if so, is there a way to force this?

many thanks,
Dmitri

0 Kudos
1 Reply
IanH
Honored Contributor III
757 Views
I've never used delay loading, but...

I don't know whether the matlab static libraries are just import libraries for the DLLs (probable, after quickly looking at the list of library and DLL exports) or whether they also contain some code to assist with interfacing. If the former, then you could always use LoadLibrary and GetProcAddress to dynamically access the required Matlab API's, which would avoid the problem with load time dependencies, but you are then at the mercy of the Mathworks changing the otherwise private DLL interface.

But an easier and more robust solution might be to write your own (hopefully thin interface) DLL, that you either delay load into your executable (or use dynamic loading, which is what I'm more familiar with) only when matlab interfacing is required. Your interface DLL statically links against the matlab libraries so it will have a load time dependence on the Matlab DLL's (but the EXE won't).
0 Kudos
Reply