views:

153

answers:

6

I am working on a legacy C++ project and missing a third party dll. I was told that the dll will be available in two weeks. The work that I need to perform is pure UI. I don't really need the dll. However, the application won't run without the dll. Should I comment out all the places that the dll get called or create a place holder dll, either way there are tons of APIs to cover? Doesn't anybody have a better idea?

+5  A: 

I'd create a stub DLL that does nothing (or as little as you need it to do). Then when you get the real one, drop it on top of your stub and you're done.

If there are a zillion functions you need to create, you might be able to use perl or some other scripting language to help turn your slew of linker errors into a file containing prototypes of the functions you need.

Graeme Perrow
A: 

You won't get far. With that many calls, writing a wrapper is a bad use of time unless you're in prison or something.

You can't take a copy of the DLL from a running installation? Or is this a licensing problem?

Joe
Prison... really?
Aardvark
+1  A: 

Write unit tests. Otherwise, sounds like two weeks of thumb twiddling is in order.

Rob K
A: 

Me, I'd attempt to duplicate the .DLL here licensing and other issues notwithstanding. Other than that find another project I think...

tekiegreg
+3  A: 

If you have access to the source code of the EXE (it seems so), and you're running any recent Visual Studio (6 or later), an easy solution is to rebuild with /DelayLoad. This means the linker will set up the EXE to call LoadLibrary and resolve imports at the first call. This means that if you don't actually call the DLL, it's never loaded, and by extension, not missing.

This means you do not have to create any stub DLL; it's a 5 minute change.

MSalters
+1  A: 

I usually dynamically load non-essential DLLs via LoadLibrary and GetProcAddress calls so my applications can run without them. The application can check if the DLL was loaded, and if not, it doesn't offer the functionality the DLL provides. I have used this with spell checkers, barcode libraries, etc. Might be something to consider.

Rob