Is it possible to automatically link a c++ static library in Visual Studio 2008? Or, is there an improvement to use from the standard approach?
I am developing a set of c++ libraries and linking/testing them is quite a pain. The usual approach is to specify the .lib files in the test clients, but now the list has grown quite large (my own libs, opencv, boost, and others) and I’m always missing something as I switch between debug and release modes, gpu and non-gpu, etc. When I open the linker in project properties the list scrolls on for some time.
I was hoping that I could automatically specify that if a client #includes something that the project should also link to a specified .lib (debug/release). Is this possible or is there an alternate approach that will help manage linkage with minimal user interaction?
Use
#pragma comment(lib, "name_of_the_library.lib"). Other useful options for#pragma commentcan be found at the MSDN page.With regard to Debug vs. Release configuration: usually a _DEBUG preprocessor macro is used to distinguish. Visual C++ header certainly use it for the same purpose as you want; e.g. this is from VC++ 2010
use_ansi.hfile: