Code-Generation options
-
Hi, I was wondering what is the difference of "Multithreaded" and "Multithreaded DLL" options on the Code-Generation tab of the VC++. I used to compile my application (composed out of several dll files) with "Multithreaded" (default option when migrated my app from VS2003 to VS2005) and it crashed randomly (some times it could even run smoothly for some reasonably long time). However when I switched the option to "Multithreaded DLL" the random crashes didn't occur any more. Thank you.
-
Hi, I was wondering what is the difference of "Multithreaded" and "Multithreaded DLL" options on the Code-Generation tab of the VC++. I used to compile my application (composed out of several dll files) with "Multithreaded" (default option when migrated my app from VS2003 to VS2005) and it crashed randomly (some times it could even run smoothly for some reasonably long time). However when I switched the option to "Multithreaded DLL" the random crashes didn't occur any more. Thank you.
This affects how the C runtime library (which contains all the "standard" functions) is linked. "Multithreaded DLL" links the DLL version: you need to redistribute vcrt.dll etc. "Multithreaded" links the libraries statically: you have less dependencies, but your binary gets bigger. For MFC applications, Runtime linkage must match MFC linkage.
Themis wrote:
it crashed randomly (some times it could even run smoothly for some reasonably long time). However when I switched the option to "Multithreaded DLL" the random crashes didn't occur any more.
It is hard to say whether this is caused by selecting the wrong runtime (likely), or just a bug in your code that goes unnoticed when linking dynamically and may surface anytime (also likely)
Some of us walk the memory lane, others plummet into a rabbit hole
Tree in C# || Fold With Us! || sighist -
This affects how the C runtime library (which contains all the "standard" functions) is linked. "Multithreaded DLL" links the DLL version: you need to redistribute vcrt.dll etc. "Multithreaded" links the libraries statically: you have less dependencies, but your binary gets bigger. For MFC applications, Runtime linkage must match MFC linkage.
Themis wrote:
it crashed randomly (some times it could even run smoothly for some reasonably long time). However when I switched the option to "Multithreaded DLL" the random crashes didn't occur any more.
It is hard to say whether this is caused by selecting the wrong runtime (likely), or just a bug in your code that goes unnoticed when linking dynamically and may surface anytime (also likely)
Some of us walk the memory lane, others plummet into a rabbit hole
Tree in C# || Fold With Us! || sighistIt could be that the original poster has used
CreateThread
rather than_beginthreadex
. UsingCreateThread
does not initialise the C run-time's internal data structures for the thread, and is unsafe in C code unless you really know what you're doing. Using the C run-time DLL allows you to get away with callingCreateThread
because it does the necessary initialisation in the DLL'sDllMain
routine, on receiving theDLL_THREAD_ATTACH
notification. Stability. What an interesting concept. -- Chris Maunder