Sign in to follow this  
someboddy

[VC++2008]Compiling .LIB files for both debug and release

Recommended Posts

I've compiled my engine(based on SDL[with SDL_image and SDL_ttf] and OpenGL) as a LIB file(first time I make a LIB file), but when I tried to use it I encountered a weird problem: if I compile a project in debug mode with a LIB compiled in release mode or a project in release mode with a LIB compiled in debug mode and try to run it, it crashes at the game loop function(the initialization functions works fine). If I use release LIB for release mode or debug LIB for debug mode it works fine. Is there a way to compile a LIB so it'll work on both debug and release modes? Also, is it possible that 100+ warnings in my code cause this problem?

Share this post


Link to post
Share on other sites
If you're very careful you can create a library that can be used with both debug and release builds. To do so you need to make sure that you have a clean interface that doesn't contain anything that can be affected by the implementations. This means, among other things, that you can't have inline functions in your interfaces, that memory allocated by the library needs to be deallocated by the library and that your structures all share the same alignment in both modes.

In practice, unless you're selling the library, it's just easier to name your debug and release builds something different (ex: MyLibrary.lib for release and MyLibraryD.lib for debug) and let the user build release and debug builds for their compiler version.

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