Standard C library in mingW

15,609

MinGW does not build against glibc, it builds against msvcrt. As such, it uses libmsvcrtXX.a instead.

Share:
15,609

Related videos on Youtube

KawaiKx
Author by

KawaiKx

Updated on June 21, 2020

Comments

  • KawaiKx
    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
    KawaiKx almost 13 years
    do 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
    Ignacio Vazquez-Abrams almost 13 years
    MinGW is designed to build native Windows code, and as such it builds against Windows' native libc.
  • KawaiKx
    KawaiKx almost 13 years
    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?
  • Ignacio Vazquez-Abrams
    Ignacio Vazquez-Abrams almost 13 years
    gcc 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
    Jakob Riedle over 6 years
    Please be constructive @Brian Haak. What is it instead? Just saying the answer is wrong does not help anyone.
  • Brian Cannard
    Brian Cannard over 6 years
    I 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
    jpaugh over 5 years
    Thanks, 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
    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
    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
    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 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.
  • Royi
    Royi about 4 years
    What about libm for numeric calculations? Does MinGW use that on Windows?
  • jrh
    jrh over 3 years
    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
    jrh over 3 years
    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.