views:

412

answers:

5

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.

A: 

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.

1800 INFORMATION
+1  A: 

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
demoncodemonkey
Sorry, this is nonsense. I missed the VC++ 6.0 part of the question, the above is for VS2008. I don't think VC6 allows placeholders like this. I'd go with Richard's answer.
demoncodemonkey
+1  A: 

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.

Richard
+ 1
demoncodemonkey
A: 

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.

+1  A: 

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

coolcake