GCC on Cygwin coexists with MinGW

Perhaps there are two versions of GCC: the native version of MinGW for Windows and the Linux version of cygwin? Everything becomes problematic when on Cygwin the system tries to compile the GCC MinGW version and vice versa. How can I save both versions of GCC?

+6
cygwin mingw
source share
4 answers

Mental debugging suggests that you have one or both in your global path. Take both from your global path (gcc should give a β€œbad command or file name” or a similar run directly from cmd.exe) and configure the shortcuts to load the proper environment for each.

+3
source share

I have both installed and coexist peacefully. Cygwin is installed in c: \ cygwin, and MinGW is installed in c: \ msys \ mingw. I did not have to do anything unusual so that they could coexist, since their environments are set using the appropriate launch shortcuts.

Your installation should have a certain step that made them somehow bind themselves. If you describe your installation sequence and location, maybe someone can offer more advice.

+4
source share

The way I share them is to use the default Cygwin environment exclusively. MinGW stuff is not included in my PATH by default, and I do not use MSYS programs. For everyday use, you cannot say that I have MinGW.

On those rare occasions when I need to test something with MinGW, I run this shell script from the Cygwin Bash prompt, which I call mingw :

 #!/bin/sh PATH=/cygpath/c/mingw/bin:/cygpath/c/windows/system32:/cygpath/c/cygwin/bin echo "Say 'exit' to leave MinGW shell and restore Cygwin environment." /usr/bin/bash --rcfile ~/.mingwrc 

Adjust the PATH to taste. The only important thing is that it puts the MinGW bin directory in front of the Cygwin bin directory. You probably still need the Cygwin bin directory in the PATH for vi, ls, etc.

The last line of this script runs this script, ~/.mingwrc :

 alias make=mingw32-make PS1='MinGW: \W \$ ' 

You cannot combine these two scenarios because of how Bash works. The second script contains things that can happen only after running the "MinGW shell". The PS1 assignment reminds you that you are in the MinGW shell, and the alias ensures that the input β€œmake” launches its own make (1) MinGW program instead of Cygwin, since my MinGW Makefiles use DOS commands and not Bourne shell commands, and this is one of the differences in the MinGW GNU make port. You will leave this alias if you want to use the MinGW compiler with Cygwin make.

When you β€œexit” the MinGW sub-shell, you restore the previous PS1, PATH, and aliases.

+4
source share

Take both of the global path. Then create a new *.cmd file with the following (take Cygwin as an example):

 @echo off rem file: start cmd with cygwin path cmd.exe /k path=C:\cygwin\bin;%path% 

You can enter path in the command window to check.

Now you can work with cygwin. The environment is valid only within cmd.exe .

+3
source share

All Articles