0
votes

I have two gcc's installed in cygwin right now: i686-w64-mingw32-gcc-4.5.3.exe and the cygwin gcc. Ill show you what I did for the sake of clarity:

$ ls -al /usr/bin/gcc*
lrwxrwxrwx 1 User None    21 Aug 16 13:15 /usr/bin/gcc.exe -> /etc/alternatives/gcc
-rwxr-xr-x 2 User None 94741 Feb 25  2009 /usr/bin/gcc-3.exe

$ ls -al /etc/alternatives/gcc*
lrwxrwxrwx 1 User None 18 Aug 16 13:15 /etc/alternatives/gcc -> /usr/bin/gcc-3.exe

$ rm /etc/alternatives/gcc

$ ln -S /usr/bin/i686-w64-mingw32-gcc-4.5.3.exe /etc/alternatives/gcc

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
Target: i686-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/32gcc/mingw64-i686-gcc-4.5.3-6/src/gcc-4.5.3/configure --srcdir=/cygdrive/i/szsz/tmpp/32gcc/mingw64-i686-gcc-4.5.3-6/src/gcc-4.5.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/mingw64-i686-gcc -C --build=i686-pc-cygwin --host=i686-pc-cygwin --target=i686-w64-mingw32 --with-sysroot=/usr/i686-w64-mingw32/sys-root --with-build-sysroot=/usr/i686-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,ada,c++,fortran,objc,obj-c++ --enable-fully-dynamic-string --enable-libgomp --enable-sjlj-exceptions --enable-version-specific-runtime-libs --with-dwarf2 --enable-decimal-float=bid --enable-lto
Thread model: win32
gcc version 4.5.3 (GCC)

$ gcc -o test test.c
gcc: error trying to exec 'cc1': execvp: No such file or directory

$ /usr/bin/i686-w64-mingw32-gcc.exe -o test test.c

$ 

How do I get gcc to work?

2

2 Answers

-3
votes

If you need a native MinGW-w64 GCC, use a native Windows version of the compiler and call it from cmd or if you must MSYS. If not, use the Cygwin to Windows cross-compiler and encode the prefix in a Makefile/CMakeLists.txt/configure script.

Remember Cygwin != Windows, and what you are doing is cross-compiling, which in GCC land is done by calling prefixed binaries.

-1
votes

I think you need to change the gcc symlink in /usr/bin to point to your correct version of GCC. Alternatively, you can edit your PATH to have /etc/alternatives come before /usr/bin, but that may have unintended side effects, depending on your setup.