This is a easy to use library which let you use different compilers, to
optimize-compile your DLL for different processors.
Move all the to be optimized classes and functions to a DLL, and the
DelayLoader library will automatically import all the functions from the fastest
(for this processor available) DLL.
There are 4 projects included:
- DelayDLL, a library project which is the one to use in your own workspaces
- MainDLL, a sample DLL which exports a function
- Test, a sample DLL which exports a function
- MainMFC, a sample project which makes uses of the projects above, no fancy
MessageBox, just step through with debugger to see which
DLL is loaded. A
output is done, so you can easily see which DLL is currently loaded
The library is based on the Delay loading of DLL. So we start loading the DLL
when it is needed for the first time. No
functions need to be called, The Delay Loading from Microsoft takes care
With a specific hooking mechanism we can force our app to load a different
DLL than compile-time was programmed. We could even get the adress of a different
named function. The DelayDLL.dll should be loaded by the MainMFC program, but because
we run this program on my Athlon MP the DelayDLL.Athlon.dll file is
This hook makes it very easy when we build a program which should make use of
processor specific optimizations. The
UnloadDelayedDLL( LPSTR )
unload a DLL at runtime, to
free up memory, for if you don't have 1Gb of RAM like me :-p
Hope this is useful for you guys.
How to use
- Add the DelayDll project to your workspace.
- Set a dependency for your project to this project, the library will
automatically be linked against your exe.
Add the precompiled library delaydll.lib to your DLL's configuration.
- Add a new file to your project, so you can easy change / add new DLLs
- Make a copy of the configuration
- Select the DLL-project you want to optimize,
You could only add a copy of Win32 Release, and call it w32 Athlon Rls. Or
also make a copy of the win32 Debug, and call it w32 Athlon Dbg. The only thing you have to change in the project settings, is on the link
tab, the Output name, to MainDLL.Athlon.dll for example.
And of course you should select another compiler, for this configuration (
using the Codeplay Compiler Controller Plug-in ). Or make some assembler files yourself and use them for this configuration.
For now only compile the .c files using VectorC, so not the complete
project. ( no cpp support yet ). Of course you can also use the Intel compiler to create optimized
Here is an example of file to be added to your project, which will make use
of the optimized DLLs.
#pragma comment(linker, "/DelayLoad:Test.dll")
#pragma comment(linker, "/DelayLoad:MainDLL.dll")
DLLDescriptor TestDLL =
DLLDescriptor MainDLL =
DLLCollection pDelayLoadedDLLs =
"Test.dll", TestDLL, "Test2.dll", TestDLL, "MainDLL.dll", MainDLL, NULL