Using Debug/Release libraries in MS VC++.

I have a project in MS VC++ 6.0 that needs to link to .LIB files.  I ussually just do this by including the .LIB file in the project workspace.  The problem is that I need to use a different .LIB file in the debug and release versions.  How do I do that?  (Without changing the workspace each time I change configurations.)  Note the 2 .LIBs have same name, but are in different directories.
LVL 22
nietodAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jkrConnect With a Mentor Commented:
That's exactly why i prefer such a solution for common libraries that are used in a lot of projects - just add the statement to the header, include the header ... et voila ;-)

0
 
MirkwoodCommented:
What is the problem? You can just add the lib file link setting in the project file
0
 
nietodAuthor Commented:
I'm not sure what you mean or where/how to do it.  As I said, the only way I've done this before is to place the file in the project workspace.  That file has to be at a specific path that (as far as I can tell) can't change depending on the current configuration.)
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jkrCommented:
nietod, you might want to try the following:
#ifdef _DEBUG
#pragma comment( lib, "debug.lib")
#else
#pragma comment( lib, "release.lib")
#endif


0
 
nietodAuthor Commented:
That looks promissing.  I'll try that in a few minutes.  (That's programmer minutes.)  I'll let you know.  
0
 
plarocheCommented:
In developer studio, you do have two build configurations, one debug and one release?

If so, go in the project setting dialog (MENU PROJECT - CHOICE SETTINGS).

In that dialog you will see a combo box where you can select a build configuration, debug or release.
Select debug, go in the LINK property page.
Select the INPUT combo option.
Add your lib file in the appropriate edit box there.

Next select your release project build configuration.
In the same edit box add the other lib file for your release build.
0
 
cyrilbdtCommented:
Mirkwood is right. Alt+F7|Link - General. type your debug lib, BUT from Settings for choose debug.
0
 
nietodAuthor Commented:
plaroche, your solution might have worked but I was trying jkr's at the time you answered.  Jkr's also has the advantage that the "setting" becomes part of the source code and does not need to be manually set each time a project is created or recreated (after the project file becomes corrupt).

jkr, please answer.
0
 
nietodAuthor Commented:
That's exactly what I've done (put it in the header).

Thanks.
0
All Courses

From novice to tech pro — start learning today.