?
Solved

Loading the local msvcrt.dll instead of the system one

Posted on 2000-03-01
4
Medium Priority
?
637 Views
Last Modified: 2013-12-03
I am experiencing problems with an MFC executable built in VC6.  It needs to make use of DLLs that were built with VC4.1.  I am getting Access Violations at odd times, and I strongly suspect that there is an incompatibility between the exe and the DLLs that is causing heap corruption somehow - a couple of MSDN articles mention that this can happen when VC6 and VC4 programs share the same VC4 version of msvcrt.dll.

What I notice is that the VC6 executable, even though it has the msvcrt.dll version 6 in its local directory, is nevertheless using the msvcrt.dll version 4 that is in the system directory.  Other processes are using the version 4 DLL.  What I want is to make my VC6 program use the VC6 msvcrt.dll that is in its directory.  

I understand that normally, even if DLL 'X' is loaded in a process, another process will still load its local version of DLL 'X'.  Is this different for msvcrt.dll?  Is there a way around this?   I am using NT Server 4.

0
Comment
Question by:mcglinchey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:JMu
ID: 2573327
To solve this problem, don't use msvcrt.lib. Use libcmt.lib for Release version and libcmtd.lib for Debug version. This includes the RTL into your application.

JMu
0
 

Author Comment

by:mcglinchey
ID: 2573347
This sounds like a good idea, but I was under the impression that MFC applications can only be linked with the run-time msvcrt.dll.  When I go Project->Settings->C/C++->"Use run-time library" and choose "multithreaded" instead of "multithreaded DLL", then the compiler complains with:

"fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds"

Is there another way to statically link with the C run-time libs?
0
 
LVL 1

Expert Comment

by:JMu
ID: 2573405
C++ code generation: Use run-time library: Multithreaded

Link Input: add libcmt.lib to Object/library modules.

Build your application. If linker shows duplicate symbol errors, add msvcrt.lib to Ignore libraries. I have never tried this.

BTW. I always check Ignore all default libraries, if I write non-MFC application.

JMu
0
 
LVL 23

Accepted Solution

by:
chensu earned 600 total points
ID: 2574773
INFO: Windows NT Uses KnownDLLs Registry Entry to Find DLLs
http://support.microsoft.com/support/kb/articles/Q164/5/01.asp
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question