I have installed mingW to use gcc, platform windows 7. I am trying to locate the standard C library libc.a in mingW folder. no luck.. is it stored in some other name?
            Asked
            
        
        
            Active
            
        
            Viewed 1.8k times
        
    1 Answers
19
            MinGW does not build against glibc, it builds against msvcrt. As such, it uses libmsvcrtXX.a instead.
        Ignacio Vazquez-Abrams
        
- 776,304
 - 153
 - 1,341
 - 1,358
 
- 
                    1do you also know the reason why MinGW does not use its own glibc? it is confusing. I thought I have installed complete gcc compiler for C. – KawaiKx Jun 18 '11 at 08:02
 - 
                    2MinGW is designed to build native Windows code, and as such it builds against Windows' native libc. – Ignacio Vazquez-Abrams Jun 18 '11 at 08:45
 - 
                    do you mean to say that gcc own standard C library can't run on windows os/x86 chips? are they written for some other platform? – KawaiKx Jun 18 '11 at 12:55
 - 
                    6gcc and glibc are two separate products. They do not depend on each other. And Windows does not need glibc; it already *has* a libc. If you want functions beyond what msvcrt provides then there is [gnulib](http://www.gnu.org/software/gnulib/). – Ignacio Vazquez-Abrams Jun 18 '11 at 13:02
 - 
                    Please be constructive @Brian Haak. What is it instead? Just saying the answer is wrong does not help anyone. – Jakob Riedle Feb 05 '18 at 09:46
 - 
                    3I meant that one can't just link their Linux-compatible programs with msvcrt.dll, because the C APIs are different. What a dev team having resources _can_ create though is a completely Linux compliant C library using only system APIs thru kernel32.dll and other APIs without using msvcrt.dll. The desire is to have a compiler to build native code on Windows which uses standard Linux C libraries. But lightweight and performant. – Brian Cannard Feb 05 '18 at 17:15
 - 
                    2Thanks, Brian. By chance, do you know of a libc which is compatible with MinGW? I'm trying to port an app from linux, and it's not quite working. – jpaugh Oct 23 '18 at 17:29
 - 
                    @jpaugh you'll have to choose between Cygwin and MSYS2's toolchain (fork of Cygwin). Both provide POSIX-compliant emulation layers. – bit2shift Jun 02 '19 at 20:23
 - 
                    @bit2shift I was already using MinGW to build the program. Unfortunately, I can't remember which program, but I believe I was trying to port tmux. I got stuck on some Unicode issue. I solved that problem by switching to [MSYS2](https://www.msys2.org/), which packages a pre-built tmux, installable via `pacman -S tmux`. – jpaugh Jun 03 '19 at 14:26
 - 
                    @jpaugh Good call. While on Linux the narrow-char C functions (`fopen()`, etc.) are encoding-agnostic, the same is not true for MinGW with `msvcrt.dll`, where such functions use the system's ANSI code page (ACP) to convert to and from UTF-16. Unfortunately, the UTF-8 code page on Windows, `cp65001`, is not usable as ACP before Windows 10 version 1803. – bit2shift Jun 03 '19 at 15:28
 - 
                    What about `libm` for numeric calculations? Does `MinGW` use that on Windows? – Royi Apr 26 '20 at 21:33
 - 
                    It's not very clear whether MinGW uses some version of the CRT or not, the binary it produced works on a clean version of Windows 10 without any CRTs installed, so I'd guess that either MinGW uses a very old CRT version that Windows 10 has installed by default, or MinGW statically links either a Windows compatible glibc or its own imitation of the CRT, the latter seems more likely to me because the .exe file has strings that imply some CRT header files. – jrh Dec 03 '20 at 16:02
 - 
                    For me on Ubuntu cross compiling for Windows, there's a folder named `/usr/x86_64-w64-mingw32` which has libraries and headers that sound CRT-ish but they are in file formats Windows would never use (like ar), I very much doubt these are official CRT libraries. – jrh Dec 03 '20 at 16:06