gcc found but not executing on windows git bash - windows

I installed gcc on windows via msys32. On powershell and on command prompt it executes properly.
The only strange thing: which gcc yields /usr/bin/gcc, yes with unix slashes.
In real world it is installed in ~/AppData/Roaming/msys32/usr/bin so the msys path is cut off.
In git bash gcc yields no command not found but just nothing.
Also which gcc yields /c/Users/ere/AppData/Roaming/msys32/usr/bin/gcc.
So the problem is specific for git bash, right? But I cannot interpret the outcome.
Any ideas?

Related

How do I pass an arbitrary command line argument to a native Windows program from a MinGW shell?

How do I pass an arbitrary command line argument to a native Windows program from a MinGW shell?
I would like a general solution, but a solution that works for any valid Windows filename would be acceptable.
That shell is Bash. Cygwin/MSYS2 Bash can accept Windows paths, but you need to
deal with spaces and backslashes. Regarding backslashes:
program 'C:\alfa.txt'
program C:\\alfa.txt
program C:/alfa.txt
Regarding spaces:
program 'C:\alfa bravo.txt'
program C:\\alfa\ bravo.txt
program C:/alfa\ bravo.txt
As you can see, if you are supplying Windows paths, this is pretty straight
forward. The only issue you might get is if you are trying to supply Bash paths
to a Windows native program:
program /tmp/alfa.txt
Windows native programs have no concept of /tmp or even /. Cygwin/MSYS2 have
cygpath to assist in converting these paths:
program $(cygpath -m /tmp/alfa.txt)
program "$(cygpath -w /tmp/alfa.txt)"
program "$(cygpath -m '/tmp/alfa bravo.txt')"
program "$(cygpath -m /tmp/alfa\ bravo.txt)"
program "$(cygpath -w '/tmp/alfa bravo.txt')"
program "$(cygpath -w /tmp/alfa\ bravo.txt)"
Side note: MinGW is an old project. You should be using Cygwin or MSYS2.

sh error for long command passed from make.exe on cygwin

I have a makefile with a long shell command and when I run make the shell gives the following error
/usr/bin/sh: -c: line 5: syntax error: unexpected end of file
I'm using the mingw make.exe v3.82 instead of the one shipped with cygwin.
Any idea?
a mimic of the Makefile code with similar number of characters:
_trial :
#sleep 10;if [ "sgggffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddffffffffffffffffffffffffffffffff aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa fffffffffffffffffffffffffffff zzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaa" != "sgggffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddffffffffffffffffffffffffffffffff aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa fffffffffffffffffffffffffffff zzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaa" ]; then\
echo "sgggffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddffffffffffffffffffffffffffffffff aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa fffffffffffffffffffffffffffff zzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaa";\
echo "sgggffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddffffffffffffffffffffffffffffffff aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa fffffffffffffffffffffffffffff zzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaa";\
echo "sgggffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffffffffffffddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddffffffff aa";\
fi
That worked for me on Linux, so it must be a Windows issue. I know for a fact that Windows has a much smaller limit on the size of command lines than most UNIX systems so that could be part of the problem.
Did I understand you right, that you're trying to run the mingw32 version of make inside a cygwin shell? That will not work, I don't think. I'm far from knowledgeable about Windows but I'm pretty sure you have to use cygwin tools inside cygwin, and you can't use cygwin tools outside of cygwin.
I recommend you ask your question (as well as providing all pertinent details such as the exact version of GNU make, how it was compiled, cygwin environment, etc.) on the make-w32#gnu.org mailing list: folks who know a lot about running GNU make on Windows of all stripes tend to hang out there.
Sorry for the less-than-helpful answer :-/

Can't output anything using cygwin 1.7 gcc under windows

I just installed cygwin 1.7, and wrote a simple Hello world in test.c
but when I complie, nothing happens, even no error messages
gcc-4 -o test.exe test.c
And there's nothing generated under my folder.
I have included C:\cygwin;C:\cygwin\bin in my PATH
Did I miss something?
EDIT:
for more information, I installed Qt4, tortoiseHg, and mingw before.
Now I had removed mingw. but still got Qt4 and tortoiseHg, is this a problem?
Try doing this from the Cygwin Terminal, not cmd.exe:
$ cd `cygpath -u "$USERPROFILE"`/Desktop/UT
$ gcc -o foo foo.c
$ ls -l foo
-rwxr-xr-x+ 1 yourlogin None 19618 May 10 05:15 foo*
If that works, there's some bogus remnant lying around.
You'll find that the Cygwin experience is generally better running under Bash, in a MinTTY terminal anyway. cmd.exe doesn't understand Cygwinisms, and is a DOS throwback besides.
Note that you don't need to say gcc-4 to get GCC 4.x. gcc is GCC 4.x on Cygwin, and has been for quite some time now.
Also note that you don't need to include .exe in the GCC -o flag, because Cygwin GCC knows to add that already.

Changing directory in bash for GNU

I have never worked with Linux and hence I am ignorant in the commands.However, I need to use the GNU for win64 environment for one of the programming tools to function. I have downloaded the GNU from cygwin. This package includes gcc and various commands and
shells (sh, bash, etc.) that make the PC have a unix
like environment.
I have to change to the directory of the program code MyPrograms and type "make all".
On opening the terminal of cygwin i get this line >> -bash-4.1$
Question is what is the command for changing to the directory MyPrograms;what do I type in after -bash-4.1$
If your MyPrograms folder is located at C:\MyPrograms, then in Cygwin, type:
cd /cygdrive/c/MyPrograms
Refer to this FAQ

How to stop MinGW and MSYS from mangling path names given at the command line

On Windows, I'm cross-compiling a program for ARM/Linux using CodeSourcery's cross-compiler suite. I use MinGW MSYS as my command interpreter, and very often it will mangle my paths and pathnames. For example, to build my program, I invoke
arm-none-linux-gnueabi-gcc.exe -Wall -g \
-Wl,--dynamic-linker=/usr/lib/myrpath/ld-linux.so.3 \
-Wl,-rpath=/usr/lib/myrpath \
-I../targetsysroot/usr/include \
myprogram.c -o myprogram
Of course, I want /usr/lib/myrpath inserted verbatim into the myprogram executable - the ARM Linux target I'm compiling for doesn't use MinGW or MSYS. But here's what ends up going into it:
...
0x0000000f (RPATH) Library rpath: [C:/MinGW/msys/1.0/lib/myrpath]
...
Not exactly what I wanted. If I invoke GCC on the cmd.exe command line directly, I get the right rpath in the executable. If I invoke GCC on the MSYS command line, I get the mangled rpath. If I invoke GCC with a Makefile that is run with make from the cmd.exe command line, I still get a mangled rpath (!)
Any ideas how I might turn off this annoying behavior?
There is a way to suppress the path translation by setting MSYS_NO_PATHCONV=1 in Windows Git MSys or MSYS2_ARG_CONV_EXCL="*" in MSYS2.
Alternatively, you can set the variable only temporarily just for that command by putting the assignment just before the command itself:
MSYS_NO_PATHCONV=1 arm-none-linux-gnueabi-gcc.exe -Wall -g \
-Wl,--dynamic-linker=/usr/lib/myrpath/ld-linux.so.3 \
-Wl,-rpath=/usr/lib/myrpath \
-I../targetsysroot/usr/include \
myprogram.c -o myprogram
I just discovered a neat trick to avoid MSYS/MinGW translating the paths for you.
If you use double-slash to start the path, then MSYS won't translate the path to DOS format. So in OP's example, the -rpath switch should be specified like this:
-Wl,-rpath=//usr/lib/myrpath
All Unix/Linux tools seem to handle such spurious slashes without any problem, so even though your binary's rpath will start with //usr/... I think the loader will do the right thing.
I don't think there's a way to switch this off. MSYS is a fork of an old Cygwin version with a number of tweaks aimed at improved Windows integration, whereby the automatic POSIX path translation when invoking native Windows programs is arguably the most significant. The trouble with that is that it isn't always possible to tell whether an argument is a path or something else, or whether, as in this case, it is in fact a path that nevertheless shouldn't be translated. The translation is guided by a set of heuristics.
You could try using MinGW make instead of MSYS make (yes, they're different things), which is a native Windows build of make without POSIX path support and conversion. Install with mingw-get install mingw32-make and invoke as mingw32-make.
Or you could try Cygwin, ideally with a Cygwin build of the toolchain.
Indeed, in the original MSYS project provided by MinGW.org, there is no way to disable the Posix path conversion.
That's why I made a little fork of the msys-core runtime which supports the MSYS_NO_PATHCONV flag introduced with the Git for Windows fork. In that way, you may use MSYS_NO_PATHCONV environment variable as in the Git for Windows but in the original MinGW/MSYS.
So in summary, to disable this Posix path convesion:
For MSYS2 (built-in): MSYS2_ARG_CONV_EXCL="*"
For Git for Windows (built-in): MSYS_NO_PATHCONV=1
For MinGW.org (with msys-core-extended): MSYS_NO_PATHCONV=1.
export MSYS_NO_PATHCONV=1 was necessary in my case on git-bash on windows (as noted by dx_over_dt above. )
Unfortunately putting two forward slashes for this example doesn't work as expected.
rsync -rvztn --delete --exclude="/application/logs/" ...
I want 'rsync' to exclude files only at /application/logs which is at the top level, hence the leading forward slash. Adding two forward slashes will not cause it to exclude this directory. I have to resort to the less accurate --exclude="application/logs/".

Resources