views:

28

answers:

1

If I wanted to add, let's say, a new .lib to the build only if a particular #define was set, how would I do that?

In the MSVC++ 2008 "Property Pages", you would simply add: Config Properties -> Linker -> Input -> Additional Dependencies, but I would like it if something like #define COMPILE_WITH_DETOURS was set, then the particular library would be added to the dependencies, otherwise it would be removed.

Thanks!

+2  A: 

You can set some linker options by using #pragma comment in one of your source files.

For example, to link against a 'detours.lib' library only if COMPILE_WITH_DETOURS is defined, you can use:

#ifdef COMPILE_WITH_DETOURS
#    pragma comment(lib, "detours.lib")
#endif

(this is specific to Microsoft Visual C++ and is not portable)

James McNellis