Vis-Sim.com Forums Forum Index Vis-Sim.com Forums
3D Real-Time Simulation Services, Resources and Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Care with mixing Debug and Release Libs

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Vis-Sim.com Forums Forum Index -> Tools & Tips, General Bits
View previous topic :: View next topic  
Author Message
UrbanLegend
Site Admin


Joined: 11 Apr 2005
Posts: 1143

PostPosted: Sat Apr 30, 2005 11:00 pm    Post subject: Care with mixing Debug and Release Libs Reply with quote

On Windows especially care must be taken not to mix release and debug libs, as this can be the cause of many problems with strange crashes etc.

Its quite easy to link with msvcprtd.lib and msvcprt.lib for example when using 3rd party libs.

One must ensure that this doe not happen using compiler directive nodefaultlib

I usually do this using the #pragma commands e.g

Code:
#pragma once

#ifdef _DEBUG

//
//   We are Building with Debug Multi-thread  /MDd so
//
//  Tell the Linker to NOT link in the following modules
//
#pragma comment(linker, "/nodefaultlib:libc")
#pragma message( "DEBUG Build : NOT linking with  " "libc.lib" )

#pragma comment(linker, "/nodefaultlib:libcmt")
#pragma message( "DEBUG Build : NOT linking with  " "libcmt.lib" )

#pragma comment(linker, "/nodefaultlib:libcd")
#pragma message( "DEBUG Build : NOT linking with  " "libcd.lib" )

#pragma comment(linker, "/nodefaultlib:libcmtd")
#pragma message( "DEBUG Build : NOT linking with  " "libcmtd.lib" )

#pragma comment(linker, "/nodefaultlib:msvcrt")
#pragma message( "DEBUG Build : NOT linking with  " "msvcrt.lib" )

#pragma comment(linker, "/nodefaultlib:mfc42")
#pragma message( "DEBUG Build : NOT linking with  " "mfc42.lib" )

#pragma comment(lib, "msvcprtd.lib")
#pragma message( "DEBUG Build : Will automatically link with " "msvcprtd.lib" )

#pragma comment(lib, "msvcrtd.lib")
#pragma message( "DEBUG Build : Will automatically link with " "msvcrtd.lib" )


#endif




Last edited by UrbanLegend on Thu Oct 26, 2006 8:31 pm; edited 3 times in total
Back to top
View user's profile Send private message
onion
User


Joined: 12 Apr 2005
Posts: 10
Location: UK

PostPosted: Sat Apr 30, 2005 11:39 pm    Post subject: Reply with quote

I know what you mean about missing debug and release libraries. This can sometimes be really frustrating, especially if you are using a workspace which depends on multiple projects. It only takes one 'd' or 't' in the wrong place to get weird behaviour.
Back to top
View user's profile Send private message
UrbanLegend
Site Admin


Joined: 11 Apr 2005
Posts: 1143

PostPosted: Sun May 01, 2005 10:28 am    Post subject: Reply with quote

Yep a lot of heart ache can happen Crying or Very sad

This were I really dislike MS and Visual Studio

The compiler/linker should be a little more intelligent and only link in only one version of a library, which by default would be the release version

It would save a lot fo grief
Back to top
View user's profile Send private message
UrbanLegend
Site Admin


Joined: 11 Apr 2005
Posts: 1143

PostPosted: Sun May 01, 2005 11:18 am    Post subject: Reply with quote

This what MS recommends for link and not linking libs in

To use these run-time libraries use: /NODEFAULTLIB:msvcrtd.lib for example


Single-threaded (libc.lib)

  • libcmt.lib
  • msvcrt.lib
  • libcd.lib
  • libcmtd.lib
  • msvcrtd.lib

Multithreaded (libcmt.lib)

  • libc.lib
  • msvcrt.lib
  • libcd.lib
  • libcmtd.lib
  • msvcrtd.lib

Multithreaded using DLL (msvcrt.lib)

  • libc.lib
  • libcmt.lib
  • libcd.lib
  • libcmtd.lib
  • msvcrtd.lib

Debug Single-threaded (libcd.lib)

  • libc.lib
  • libcmt.lib
  • msvcrt.lib
  • libcmtd.lib
  • msvcrtd.lib

Debug Multithreaded (libcmtd.lib)

  • libc.lib
  • libcmt.lib
  • msvcrt.lib
  • libcd.lib
  • msvcrtd.lib

Debug Multithreaded using DLL (msvcrtd.lib)

  • libc.lib
  • libcmt.lib
  • msvcrt.lib
  • libcd.lib
  • libcmtd.lib


Last edited by UrbanLegend on Fri Jul 08, 2005 11:02 pm; edited 1 time in total
Back to top
View user's profile Send private message
UrbanLegend
Site Admin


Joined: 11 Apr 2005
Posts: 1143

PostPosted: Sun May 01, 2005 11:27 am    Post subject: Reply with quote

Note you can add /VERBOSE:LIB to the link line to get a full output of the Libs being searched by the linker
Back to top
View user's profile Send private message
Hollybbage
Guest





PostPosted: Fri Jun 21, 2019 9:40 am    Post subject: Reply with quote

3 D simulation service is the forum of the release lib at the tool of the general bits with the node fault occurs. The care with the mixing of the best essay is for the best essay in making the stimulus formation and the climax occurring situation.
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Vis-Sim.com Forums Forum Index -> Tools & Tips, General Bits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SwiftBlue Theme created by BitByBit
Powered by phpBB © 2001, 2002 phpBB Group