cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: VC8 Makefiles

From: Yang Tse <yangsita_at_gmail.com>
Date: Thu, 15 Mar 2007 19:33:59 +0100

2007/3/15, Jonathan Arnold wrote:

> I don't see any definitive reason why statically linking a DLL is a "bad
> thing".

Mainly It has to do with the following...

If you build a DLL with C runtime static linkage you will use for the
code inside the DLL the MS static C runtime.

On the contary, if you build a DLL with C runtime dynamic linkage you
will use for the code inside the DLL the MS dynamic C runtime.

If afterwards you build a program in which you use both kinds of DLLs
you will end up with a program in which part of the code is using the
MS static C runtime and other parts the dynamic one.

The biggest problem with that setting is that most probably at some
point resources allocated by the MS static C runtime will be free'd by
the MS dynamic C runtime or the other way round. And the fact is that
since Windows has existed, each runtime has kept separate
lists/counters for some resources. I'm unable to tell you exactly
which ones.

I cannot elaborate further but mixing static and dynamic MS C runtimes
in a single program sooner or later breaks it with no apparent reason.
At least funny messages as "the memory cannot be read or written"
happen and in other cases it just crashes.

Of course, if the program uses no dynamic resource at all, most
probably it doesn't matter which MS C runtime you link what with what,
it will very likely work.

It is also easier to get this crashes on programs that are mixing MS C
runtimes on debug built DLLs/programs. Go figure.

-- 
-=[Yang]=-
Received on 2007-03-15