I have a program that calls functions from foo.dll in one configuration, and has a second configuration that does not use foo.dll. I want to require foo.dll to be present only when needed. I currently switch between the two versions using
#define FLAGVAR 0
or
#define FLAGVAR 1
where FLAGVAR==1 means foo.dll is used. I then surround my import statements and function declarations like this:
#if FLAGVAR == 1
#import "foo_file.h"
#endif
...
#if FLAGVAR == 1
int foobar() {...}
#endif
If I include foo.dll in Linker->Input->Additional Dependencies, then my program builds regardless of FLAGVAR's value.
Here's my problem:
I don't want to require foo.dll to be present in versions where FLAGVAR == 0. Thus, I moved foo.dll to Linker->Input->Delay Loaded DLLs. Now if FLAGVAR==0 then it doesn't require foo.dll and builds fine. However, if FLAGVAR==1, then I get a bunch of LNK2019 errors complaining that the functions from foo.dll couldn't be linked.
How can I accomplish my goal of only requiring foo.dll when FLAGVAR==1? Am I using delayed dll loading incorrectly? Thanks in advance for your help!
Using Visual Studio 2017, version 15.4.5