We help IT Professionals succeed at work.

Using Debug/Release libraries in MS VC++.

nietod
nietod asked
on
207 Views
Last Modified: 2010-04-01
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.
Comment
Watch Question

Commented:
What is the problem? You can just add the lib file link setting in the project file

Author

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.)
jkr
CERTIFIED EXPERT
Top Expert 2012

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


Author

Commented:
That looks promissing.  I'll try that in a few minutes.  (That's programmer minutes.)  I'll let you know.  

Commented:
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.

Commented:
Mirkwood is right. Alt+F7|Link - General. type your debug lib, BUT from Settings for choose debug.

Author

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.
CERTIFIED EXPERT
Top Expert 2012
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
That's exactly what I've done (put it in the header).

Thanks.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.