Standard C library in mingW
15,609
MinGW does not build against glibc, it builds against msvcrt. As such, it uses libmsvcrtXX.a instead.
Related videos on Youtube
Author by
KawaiKx
Updated on June 21, 2020Comments
-
KawaiKx almost 4 years
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?
-
KawaiKx almost 13 yearsdo 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.
-
Ignacio Vazquez-Abrams almost 13 yearsMinGW is designed to build native Windows code, and as such it builds against Windows' native libc.
-
KawaiKx almost 13 yearsdo 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?
-
Ignacio Vazquez-Abrams almost 13 yearsgcc 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.
-
Jakob Riedle over 6 yearsPlease be constructive @Brian Haak. What is it instead? Just saying the answer is wrong does not help anyone.
-
Brian Cannard over 6 yearsI 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.
-
jpaugh over 5 yearsThanks, 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.
-
bit2shift almost 5 years@jpaugh you'll have to choose between Cygwin and MSYS2's toolchain (fork of Cygwin). Both provide POSIX-compliant emulation layers.
-
jpaugh almost 5 years@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, which packages a pre-built tmux, installable via
pacman -S tmux
. -
bit2shift almost 5 years@jpaugh Good call. While on Linux the narrow-char C functions (
fopen()
, etc.) are encoding-agnostic, the same is not true for MinGW withmsvcrt.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. -
Royi about 4 yearsWhat about
libm
for numeric calculations? DoesMinGW
use that on Windows? -
jrh over 3 yearsIt'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 over 3 yearsFor 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.