Advertisement

DLL DiLLema.

Started by February 16, 2000 02:03 PM
1 comment, last by fredo 24 years, 7 months ago
Ok. So I''ve got several different Matrix/Vector DLL''s each with code optimized for a different processor (i.e Pentium, Pentium Pro, Pentium 3, K7 ...etc). The code contained in these DLL''s are CLASSES not straight C functions. When my program starts, I want to be able to detect the CPU type and load the correct DLL in. I don''t want to use the LoadLibrary function method, because it''s little wierd with classes. The only other method I know of is DELAYED IMPLICIT DLL loading, but there is little documentation on that. Anyone got any suggestions? Thanks ~-------------------------------------------------------~ Fred Di Sano System Programmer - Artech Studios (Ottawa.CA) ~-------------------------------------------------------~
~-------------------------------------------------------~ Fred Di Sano System Programmer - Artech Studios (Ottawa.CA)~-------------------------------------------------------~
From what I know,

If you want to explicity load a dll at runtime, ::LoadLibrary() is the only way to go. Otherwise, you can just ignore dlls, and link to the libs of all your different dlls during compilation, but that would lead to serious bloat.

However, if you want abstraction in your program, and transparently want to work with whatever class has been loaded during startup, then I what I would do is to define an abstract base matrix class, and/or a pure virtual interface that lets you work with it. Then have all your optimized classes inherit from that. Make sure that your dll exports the interface and then with some work you should be able to work with whatever matrix class has been loaded without knowing which processor it has been optimized for.

Another way to do it, would be to just include all the matrix code directly into the project with all the specialized classes inheriting from the same base class, and then have a matrix maker function pointer which you set to point to the correct creation function on startup, once you detect the cpu type. I think this would be the fastest way to do it.
Advertisement
The Microsoft Systems Journal, about a year ago did a magazine, where the theme was use of the DELAYLOAD flag for DLLs. You might get more useful examples out of that. The articles might be in the current MSDN Library CDs now.

This topic is closed to new replies.

Advertisement