Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Loading the local msvcrt.dll instead of the system one

Posted on 2000-03-01
4
Medium Priority
?
643 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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