tags:

views:

42

answers:

2

Hi!

A library i'd like to use makes calls to functions like "malloc_dbg" which are defined in libcmtd.lib but not in libcmt.lib (so I get Linker errors in Release mode)

Do I really need to use the debugversion of that lib even in releasemode? or can I somehow use libcmt.lib and libcmtd.lib together, but use libcmtd.lib only for this other library and use the releaseversion for the rest of my application?

Thanks!

+2  A: 

Maybe you can implement malloc_dbg yourself and call malloc from there?

But this is just a workaround. The lib you are using should provide you a release version without these calls!

Philipp
i thoght of that too - but where would I have to implement malloc_dbg for this to work?
Mat
Implement it in your app, or in a static lib and link it in your project. so long as the linker can find it you should be ok.
OJ
A: 

Since your question is

c++ What to do if Library makes use of debug version of other library?

Here's my advice, in this order:

  1. Don't use this library. -- If the library doesn't even provide a proper release version, then it isn't fit for anything.
  2. If you must, and as in your case it appears that the lib requires the static debug version of the runtime lib, then try to create a wrapper around this library so that your project can compile with proper settings.
  3. Compile your project with the debug libraries. If you link statically to the runtime libraries, then you wont have a problem with redistribution and for small stuff it may be acceptable to use this approach.

Since you write in the comment you have this problem with GLUI I assume the fault is with you, not with the library. GLUI is an open source project, so you should be able to compile the lib (even an old version) with the appropriate settings for your environment.

Martin
yes i know - but I have source only for the current version and that one somehow doesn't want to run together with MFC and CRT. How would I create such a wrapper?
Mat
At the moment you probably shouldn't invest time in creating a wrapper but in getting the current version of this lib to run! :-)
Martin