Cygwin: How to actually use gcc-mingw

47,693

Solution 1

As you already found, you can use gcc-3 with -mno-cygwin. The other possibility is to install the 32-bit and/or 64-bit toolchains from the MinGW-w64 project, which have been packaged for Cygwin very recently and hence are available through setup.exe now. Don't be put off by the rather confusing executable names: i686-w64-mingw32-gcc is the 32-bit compiler and x86_64-w64-mingw32-gcc is the 64-bit one.

Solution 2

Further searches revealed that the MinGW-targeted cross-compiler is not ready yet, and that one has to either use GCC v3 with -mno-cygwin, or install a cross-compiler manually (see link above)...

Solution 3

Cygwin homepage says that "Individual packages like bash, gcc, less, etc. are released independently of the DLL.".

Here you can find how to install gcc under cygwin, so you should also select gcc package during install not only gcc-mingw.

Solution 4

After installing the MingW g++ package for Cygwin (mingw64-x86_64-gcc-g++), I also struggled to figure out how to invoke it.

Thanks to this wiki, I found out the command was x86_64-w64-mingw32-g++. Then I did alias g++='x86_64-w64-mingw32-g++' and g++ started working as expected.

Share:
47,693
DevSolar
Author by

DevSolar

Computer addict since the C64, Software Engineer since 2000. Unless otherwise noted, all my sources are released under ​Creative Commons CC0 (i.e., Public Domain for all practical purposes except in name due to a braindead restriction in German copyright law). SOreadytohelp

Updated on July 09, 2022

Comments

  • DevSolar
    DevSolar almost 2 years

    Since "gcc -mno-cygwin" does not work anymore, I was looking for a way to get a MinGW-targeted GCC running within my Cygwin environment. (Running a MSYS environment is not an option at this point.)

    The Cygwin installer offers a package "gcc-mingw", which installs, among others:

    lib/gcc/i686-pc-mingw32/3.4.4/cc1.exe
    lib/gcc/i686-pc-mingw32/3.4.4/collect2.exe
    lib/gcc/i686-pc-mingw32/3.4.4/crtbegin.o
    lib/gcc/i686-pc-mingw32/3.4.4/crtend.o
    

    What is absent is the "gcc" frontend. So, how do I actually invoke this compiler? I hopefully don't have to go through "cc1" manually, have I?

    I googled, but couldn't find anything relevant on the subject...

  • DevSolar
    DevSolar over 13 years
    I have installed (among others) gcc, gcc4, and gcc-mingw. My question is how to actually reach the MinGW-targeting GCC. "gcc" obviously doesn't do it, "gcc -mno-cygwin" neither, and there is no such thing as a "gcc-mingw".
  • rics
    rics over 13 years
    I see it is not so simple as I first thought. Here (cygwin.com/ml/cygwin/2009-10/msg00061.html) I found a possible solution.
  • rics
    rics over 13 years
    I also found this do-it-yourself solution: sourceforge.net/apps/trac/mingw-w64/wiki/…
  • DevSolar
    DevSolar over 13 years
    This actually works. Any idea why they keep an apparently non-functional package "gcc-mingw" in there and hide the working stuff as "i686-w64-mingw32-gcc"?
  • ak2
    ak2 over 13 years
    I think the gcc-mingw packages are part of the gcc-3 -mno-cygwin functionality. They don't actually contain anything except postinstall scripts that create links which I guess are needed for that. Those funny names follow the usual target triplet pattern for cross-compilers: cpu-vendor-os, with vendor==w64 (for MinGW-w64) and os==mingw32 (for hystorical reasons).
  • Chris Krycho
    Chris Krycho almost 12 years
    Note that as of June '12 at least, the string to run the MinGW compiler from Cygwin after installing the toolchain is simply mingw-gcc. This resolves the issue raised by the comments in the post below.
  • thoni56
    thoni56 over 11 years
    Just be careful which mingw-toolchain you use. The "true" mingw32 is win32-based ("mingw-gcc" probably being from that and not from the cygwin gang) and use Windows paths e.g. They are thus somewhat incompatible with the cygwin native versions (producing .d files with different path notations etc.). The cygwin-based gcc4 cross-compiler is one of the two mentioned in the answer.