News for hackers. Stuff that matters.
Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by rossy on Friday April 11, 2014 @10:55PM (#7576794)
The discussion in the comments is interesting. MinGW, the compiler for VLC, LibreOffice and most other FOSS projects on Windows does exactly what Raymond says not to do. In fact, the entire purpose of MinGW is to make GCC able to target msvcrt.dll. Developers and users love this, since they don't have to distribute and install the CRT with the program. Developers following the GPL aren't even allowed to distribute the CRT with their program, so they have to use one already present on the system.

Though Raymond is correct. The MinGW guys should probably "write and ship their own runtime library," or at least use the msvcrt from ReactOS or Wine. That should make it possible to statically link to it.

Having said that, Microsoft probably won't change their msvcrt.dll in a way that breaks MinGW software, since their users will complain that they broke VLC.

Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by jbk on Saturday April 12, 2014 @01:52AM (#7577112)
> MinGW, the compiler for VLC, LibreOffice and most other FOSS projects on Windows does exactly what Raymond says not to do.

While this is mostly true, and because of the project of VLC on WinRT (Windows Metro), VLC can now link, in a MinGW environment, to MSVCR80, 90, 100 and 110.

The main problem with all those, is that we cannot redistribute MSVCR*.dll for licensing reasons.

Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by yuhong on Friday April 11, 2014 @10:57PM (#7576800)
Not to mention all the other older programs that was compiled with VC4/5/6.
Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by rwallace on Saturday April 12, 2014 @07:06AM (#7577556)
MinGW relies on dynamic linking? I'm surprised at that because when I ran a test just now, Microsoft C++ compiles Hello World to an 84k executable whereas MinGW generates a 261k executable. I always assumed MinGW was doing the right thing and linking statically against (its own version of) the standard library; if not, where does the extra file size come from?
Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by aninteger on Saturday April 12, 2014 @10:08AM (#7577861)
That's probably because you wrote C++ and are usimg C++ streams. Try just using printf. The binary, after stripping, will be much smaller (I think less than 20k). You can use DependencyWalker to check what DLLs you are linking to.
Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by rwallace on Saturday April 12, 2014 @11:24AM (#7578066)
Ah, I was using C but I didn't realized needed to strip the binary, after doing that it comes down to 39k which is smaller than the Microsoft equivalent so you're right, it does seem to be using dynamic linking :(
Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by userbinator on Saturday April 12, 2014 @12:13PM (#7578227)
For comparison, VC6 defaults give 40K (statically linked), switching to dynlink shrinks it to 16K, add a few more switches and it drops to 1.5K.

Is it possible to do that with the latest versions (i.e. linking to their CRT instead of MSVCRT.DLL), or are they incapable of doing it for some odd reason? These are the options I used:

/MD /O1 /Os /link /align:4096 /filealign:512 /merge:.rdata=.text /merge:.data=.text /section:.text,EWR

Re:Windows is not a Microsoft Visual C/C++ Run-Time delivery... by aninteger on Saturday April 12, 2014 @12:35PM (#7578298)
Well, yes and no. Yes it does link to msvcrt.dll but it also brings in its own runtime too statically (mingwrt). Standard mingw links libgcc dynamically but you can use TDM gcc if you want to link it statically. I can't think of a bad reason not to use TDM gcc.