Thread: Need help understanding msvcrt.dll dependency

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446

    Need help understanding msvcrt.dll dependency

    Hello everyone,

    So far I have been building my project with the CRT dll statically linked to the executable. However I have no particular reason to do this other than this idea of mine that if I don't do it, users without the msvcrt.dll won't be able to run the application.

    Question though is, is this expected when the target systems are windows 2000 and up?

    Another question is, when I run the dependency walker on my executable, it still lists msvcrt.dll as a dependency and the dll shows as loaded on Process Explorer. What gives? Why is the dll loaded when I have it linked statically?
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> Why is the dll loaded when I have it linked statically?
    You may be using other libraries that use it dynamically. The "depends.exe" will tell you what is being used and by who.

    For VC 6.0, you can expect CRT and C++ DLL's to be there. For anything newer, you'll want to provide the needed DLL's in your own installer or use a MS redistro package like this:
    http://www.microsoft.com/downloads/d...DisplayLang=en

    gg

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by Codeplug View Post
    Why is the dll loaded when I have it linked statically?
    You may be using other libraries that use it dynamically. The "depends.exe" will tell you what is being used and by who.
    But wouldn't that generate symbol redeclaration errors in my project? However, I'll take a better look at depends and see where it is coming from..

    Quote Originally Posted by Codeplug View Post
    For VC 6.0, you can expect CRT and C++ DLL's to be there. For anything newer, you'll want to provide the needed DLL's in your own installer or use a MS redistro package like this:
    http://www.microsoft.com/downloads/d...DisplayLang=en
    I'm unsure as to how I should use that package or if I'm allowed to distribute msvcrt.dll with my executable. It seems I'm expected to direct users to that link in case they can't run my application, or simply ship my application with the CRT dll. However, this is entirely not what I see everywhere where applications developed for windows ship without any of these complications. Even those developed with wxWidgets, which is my case.

    I have tested my app on several computers. It always runs fine. But when will it not? On what occasions should I expect a user to complain with a "Windows cannot run this application" derived from the lack of msvcrt.dll?
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You will, probably with the aid of a legal professional, read the license agreement on the MS libraries - but it's highly likely that they are redistributable in a package along with your software without a license fee. It is fairly pointless to produce a compiler that allows you to build applications to or give away, if you can't then actually distribute libraries upon which those applications rely.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    If you want to play it safe with the VC 6.0 CRT files as well, there's this redistro package: http://support.microsoft.com/kb/259403.

    At the bottom there is says: "Vcredist.exe can be freely redistributed with your application."

    I image the 8.0 redistro package allows similiar use. More info here: http://msdn2.microsoft.com/en-us/lib...99(VS.80).aspx

    >> However, this is entirely not what I see everywhere...
    I've seen all kinds installations - some that assume what's needed is there, some that don't. Just for fun, do a recursive search of your Program Files directory for "MSV*.DLL".

    gg

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    > Just for fun, do a recursive search of your Program Files directory for "MSV*.DLL".

    hmm... that was scary indeed.

    Ok. Thanks both. I believe this puts me in the right track.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    If you choose to statically link then you do not need to include the DLL with your application. Thats the whole point of linking statically. The point of linking to the DLL or any DLL or using DLL's in the first place is that if the code in the DLL changes you can just give them the new DLL instead of recompiling. In the case of the msvcrt.dll, this means MS can update the library without breaking every application that depends on it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Help understanding bubblesort hw?
    By beretta in forum C Programming
    Replies: 68
    Last Post: 04-25-2009, 10:28 AM
  3. Understanding Headers
    By AeonMoth in forum C++ Programming
    Replies: 2
    Last Post: 06-27-2007, 05:53 AM
  4. trouble understanding the source file structure
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 05-26-2006, 06:46 PM
  5. understanding recursive functions
    By houler in forum C Programming
    Replies: 7
    Last Post: 12-09-2004, 12:56 PM