Sign in to follow this  
Followers 0
JohnOne

C++ static library

10 posts in this topic

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.

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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

When you say fail, what is the exact error message?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

I've never heard of UseStaticLib.obj but it sounds like you've got a header that doesn't actually match up with the binary.

Share this post


Link to post
Share on other sites

I assume the errors related to /NODEFAULTLIB are about missing symbols right?

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  
Followers 0