Re: Tricky question about Microsoft C Runtime Libraries

From: xbunny (xbunny_at_eidosnet.co.uk)
Date: 02/17/04


Date: Tue, 17 Feb 2004 19:09:33 +0000

fuh wrote:
> There are numerous C runtime libraries a win32 application or DLL may be
> linked against.
>
> Examples are singlethreaded static (/ML), multithreaded DLL (/MD) and
> multithreaded debug DLL (/MDD) .
>
> Is it possible to make a DLL use the runtime library used by application it
> is linked to?

Generally if the DLL is already linked to what its linked to
unfortunately thats it. For example if the dll is linked to one of the
static libraries then the crt is _statically_ linked into the dll
definately nothing you can do about that you couldnt even put a
different crt DLL in the path since it doesnt use one!
>
> Specifically I have an application that is compiled with /MD or /MDD
> depending on if it's a debug or release build. Depending on the compiler,
> this makes the application use mscvrt.dll, mscvr70.dll, mscvr70d.dll,
> mscvr71.dll, .... . I would like DLL's linked into the application to use
> this same runtime library (I do not want to compile a separate version of
> the DLL, one for each runtime library). The reason is so I can pass CRT
> objects from the application to the DLL without any problems.
>
> thanks.

However if the DLLs are not linked yet you can get round the compiler
switch (-MD, -MDd etc) that was included to compile them pretty easily.
Just apply -nodefaultlib to the linker and then specify the CRT library
for the link you want to use (ie msvcrt.lib).

Really though you probably want to find a design which doesnt involve
passing crt objects between seperate executable modules.



Relevant Pages

  • A solution to the MSVCRT vs MSVCR71 problem?
    ... Compile with your compiler or choice, never mind which CRT are used. ... DLL file. ... redirects CRT calls to msvcrt.dll or any other CRT of choice. ...
    (comp.lang.python)
  • Re: /MD vs /MT
    ... The /MD option causes you to use the multithreaded CRT in DLL form, ... "app+libs" means EXE plus static libraries, then of course all must use the ... same CRT flavor and be compiled with the same compiler version. ...
    (microsoft.public.vc.mfc)
  • Re: printf "fails" in extension
    ... > the example in the Python documentation, ... I'm wondering if this is a compiler issue (I'm building ... > the DLL using an Absoft compiler). ... instance of the same runtime libraries. ...
    (comp.lang.python)
  • Re: Is there a way to link dynamically to CRT on Windows CE using EVC 4.0?
    ... My guess is that 99.99% of 'delete' calls end up in coredll.dll and, if that's the case, that's common to both the EXE and DLL running in the same process. ... They could even be compiled with tools from a different compiler vendor. ... On Windows CE the CRT is implemented in CoreDLL.dll, which every process MUST load, so it can manage a single heap for all DLLs using the MS CRT. ... Thus Paul's conclusion that things should be fine under CE for allocations in one place and release in another provided all the headers describing the classes are identical between DLL and application so the proper size is allocated/freed and the layout in memory is correct. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: DLLs and facets
    ... It sounds like the EXE and DLL are using the same CRT DLL, ... must be regarded as equivalent to static linking in terms of melding your ... whenever you update the compiler. ...
    (microsoft.public.vc.stl)