Jump to content
Sign in to follow this  
JohnOne

C++ static library

Recommended Posts

VS 2010 

I made a static library, compiled it in release mode, added it to the folder of a project I want to use it in along with the header file.

It all works well in project release mode, but fails in debug mode, unless I replace release.lib with the debug.lib.

How do you deal with this, I don't get it, what if I don't have access to debug.lib?

First time I've tried to use a static library so please excuse my noobiness.

 

Share this post


Link to post
Share on other sites

If you build debug its always advisable to also link against debug lib's / dll's. Errors can occur if you don't (also runtime errors)

Share this post


Link to post
Share on other sites

I don't know what I was doing wrong, but it appears to work now after rescanning solution.

The error was along the lines of "cannot open file release.lib".

Thanks men.

Share this post


Link to post
Share on other sites

Well I'm having different issues now and these errors from vs 2010 are mind boggling.

I have my static library built in release mode in project folder and all seems to work fine in both debug and release mode.

But when I #include <iostream> I get compile time errors and warnings In debug mode.

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in UseStaticLib.obj

warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

Edited by JohnOne

Share this post


Link to post
Share on other sites

Ok, some Googling says that setting _ITERATOR_DEBUG_LEVEL to 0 in your debug build of the static library may fix this problem. If you have a precompiled header, set it there using #define.

If not using a precompiled header, just define it at the top of all your source files. Repeating the define multiple times won't hurt anything.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...