It is possible to have two versions of GCC to coexist: the native windows MinGW version and the cygwin linux version? Things get problematic when on Cygwin the system tries to c
Having both of them installed causes no harm, its just like having 2 set of files on the disk. Apparently it doesn't even clash easily.
The default one is selected in the path variable, i.e, which one is the top of the other (Note that is valid for shell executions).
Alternatively, defaults can be specified in respective IDEs. For me ,I earlier had mingw installed for which codeblocks was configured.But later when I installed Cygwin I modified the path and made it higher priority mingw was perfectly working with codeblocks.
Psychic debugging suggests you have one or both in your global path. Take both out of your global path (gcc should yield "bad command or file name" or similar run directly from cmd.exe) and set up the shortcuts so they load the proper environment for each.
The way I keep them separate is to use the Cygwin environment by default, exclusively. The MinGW stuff isn't in my default PATH, and I don't use any MSYS programs. For day to day use you can't tell I have MinGW installed at all.
In those rare instances 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 about it is that it puts the MinGW bin directory ahead of the Cygwin bin directory. You probably still want the Cygwin bin directory in the PATH for vi, ls, etc.
The last line of that script runs this script, ~/.mingwrc
:
alias make=mingw32-make
PS1='MinGW: \W \$ '
You can't combine these two scripts due to the way Bash works. The second script contains things that can only happen once the "MinGW shell" is running. The PS1 assignment reminds you that you're in a MinGW shell, and the alias ensures that typing "make" runs MinGW's own make(1) program instead of Cygwin's, since my MinGW Makefiles use DOS commands, not Bourne shell commands, and this is one of the differences in the MinGW port of GNU make. You'd leave that alias line out if you want to use the MinGW compiler with Cygwin make.
When you "exit" out of the MinGW sub-shell, you restore your previous PS1, PATH and aliases.
Take both out of global path. Then create a new *.cmd
file with the following (takes Cygwin as example):
@echo off
rem file: start cmd with cygwin's path
cmd.exe /k path=C:\cygwin\bin;%path%
You can type path
in the command window to check.
Now you can work with cygwin. The environment only be valid within the cmd.exe
.
I have both of them installed and coexisting peacefully. Cygwin is installed in c:\cygwin while MinGW is installed in c:\msys\mingw. I didn't have to do anything unusual to make them coexist since their environments are set by their respective startup shortcuts.
There must be some specific step in your installation that caused them to become coupled in some way. If you describe your installation sequence and locations perhaps someone can offer additional advice.