Re: single threaded, multithreaded compilation

From: Chuck Dillon (
Date: 10/16/03

Date: Thu, 16 Oct 2003 08:54:44 -0500

John Eskie wrote:

> In Microsofts compiler VC++ there are setting where you must choose if you
> want to compile your code as single threaded/multithreaded or MT dll. If you
> distribute libraries then you will end up having to compile the code in each
> three variants so users won't have linker problems. Can anyone explain why
> it works like this?

Because under Winders DLLs are not well designed particularly WRT how
they handle the C Runtime librarIES. The following is from the MSDN
page that documents the different compiler/linker switch that select
the C runtime to use...

Note Having more than one copy of the run-time libraries in a process
can cause problems, because static data in one copy is not shared with
the other copy. To ensure that your process contains only one copy,
avoid mixing static and dynamic versions of the run-time libraries. The
linker will prevent you from linking with both static and dynamic
versions within one .EXE file, but you can still end up with two (or
more) copies of the run-time libraries. For example, a dynamic-link
library linked with the static (non-DLL) versions of the run-time
libraries can cause problems when used with an .EXE file that was
linked with the dynamic (DLL) version of the run-time libraries. (You
should also avoid mixing the debug and non-debug versions of the
libraries in one process.)

-- ced

> So far I know GCC doesn't work the that way. Can anyone tell more on this?
> Thanks in advance.
> -- John

Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.