Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Code-Generation options

Code-Generation options

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionlounge
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Themis
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • T Themis

      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.

      P Offline
      P Offline
      peterchen
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • P peterchen

        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

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        It could be that the original poster has used CreateThread rather than _beginthreadex. Using CreateThread 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 calling CreateThread because it does the necessary initialisation in the DLL's DllMain routine, on receiving the DLL_THREAD_ATTACH notification. Stability. What an interesting concept. -- Chris Maunder

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups