user41013
user41013

Reputation: 1241

How can I link against the debug/release libraries automatically in VC++ 6.0?

I am trying to maintain a program written 5 years ago in VC++ 6.0. It uses our 'common' libraries. The trouble I have is that it either links against the debug version of these libraries or the Release version, depending on whether I have the [Directories] for [library files] set to "common/debug" or "common/release" in [Tools]->[Options].

How do I get it to link to [common\debug\common.lib] when building the debug version and [common\release\common.lib] when building the release version? If I have both paths in the library directories, it seems to link to the first one it finds.

Upvotes: 2

Views: 2726

Answers (5)

coolcake
coolcake

Reputation: 2967

Instead of specifying the paths in the include folders and all the best way i use to include the libraries depending on the configuration is by using #pragma

try this once, it is very useful

#ifdef _DEBUG
#pragma comment(lib, "..\\DllTest\\Debug\\DllTest.lib")

#else 
#pragma comment(lib, "..\\DllTest\\Release\\DllTest.lib")

#endif

Upvotes: 3

user41013
user41013

Reputation: 1241

The solution I have found is a little like Richard's & "1800 Information"'s...

I removed the Common library path from Tools->Options. The paths in here are global to all configurations of all projects running in MSVS VC++ 6.0.

I then added a full path to the appropriate library in Project->Settings for each configuration. Hense the debug configuration has D:\VSS\Common\Debug\Common.lib and the release configuration has D:\VSS\Common\Release\Common.lib. This seems to work and for the first time I have no build warnings!

Thanks to all the suggestions for pointing me in what seems to be the right direction.

--- Alistair.

Upvotes: 0

Richard
Richard

Reputation: 109100

If I have both paths in the library directories, it seems to link to the first one it finds.

Just add the debug folder for the debug settings and the release folder for release settings.

Almost all compiler, linking etc. settings are per configuration (the project properties will show settings as blank in "all configurations" (if I recall the right text) if debug and release are different.

Upvotes: 1

demoncodemonkey
demoncodemonkey

Reputation: 11957

In [Project Properties]->[Linker]->[Input]->[Additional Dependencies] you can use the $(ConfigurationName) placeholder, like this:

c:\common\$(ConfigurationName)\common.lib

In the Debug configuration this will change to:

c:\common\Debug\common.lib

and in Release it will change to:

c:\common\Release\common.lib

Upvotes: 1

1800 INFORMATION
1800 INFORMATION

Reputation: 135375

You could specify the full path of the library to link to in the Additional Dependancies field, this can have different values for debug and release builds.

Upvotes: 0

Related Questions