Solved

Using Debug/Release libraries in MS VC++.

Posted on 1998-11-25
9
157 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.
0
Comment
Question by:nietod
9 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1178622
What is the problem? You can just add the lib file link setting in the project file
0
 
LVL 22

Author Comment

by:nietod
ID: 1178623
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
 
LVL 86

Expert Comment

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


0
 
LVL 22

Author Comment

by:nietod
ID: 1178625
That looks promissing.  I'll try that in a few minutes.  (That's programmer minutes.)  I'll let you know.  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:plaroche
ID: 1178626
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
 
LVL 2

Expert Comment

by:cyrilbdt
ID: 1178627
Mirkwood is right. Alt+F7|Link - General. type your debug lib, BUT from Settings for choose debug.
0
 
LVL 22

Author Comment

by:nietod
ID: 1178628
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
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 1178629
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
 
LVL 22

Author Comment

by:nietod
ID: 1178630
That's exactly what I've done (put it in the header).

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now