Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No exe file being generated in C using recent Cygwin versions

GCC 4.9.2 does not create an executable, neither a.out or -o hello.exe. Adding -v to the compile line indicates that -o is switched to a non-existent temporary file, for example: -o /tmp/ccr6nMlO.s

Recent installs of Cygwin NT-6.1 over the last few months onto both Windows XP and Windows 7 have all failed to produce an executable. I found Cygwin 1.7.3 on an old laptop that works perfectly.

Have the compile flags or their syntax changed? This command fails to generate an executable:

gcc hello.c -o hello.exe

This is the version I have. I thought it came from a Cygwin mirror. $ uname -a gives

CYGWIN_NT-6.1-WOW Gary-PC 1.7.35(0.287/5/3) 2015-03-04 12:07 i686

Here's a compile example:

$ gcc hello.c -o hello.exe

echo $? returns a 1, without comment. So the compiler is failing.

All attempts to compile any code fails to produce anything in the current directory and no errors or warnings are reported. ctgcheck -c bash binutils bzip2 cygwin gcc-core gcc-g++ gzip m4 make unzip zip indicates everything is installed:

Cygwin Package Information
Package              Version        Status
bash                 4.3.33-1       OK
binutils             2.25-1         OK
bzip2                1.0.6-2        OK
cygwin               1.7.35-1       OK
gcc-core             4.9.2-3        OK
gcc-g++              4.9.2-3        OK
gzip                 1.6-1          OK
m4                   1.4.17-1       OK
make                 4.1-1          OK
unzip                6.0-14         OK

Compiling with -v gives this report:

$ gcc hello.c -o hello.exe -v

Using built-in specs. 
COLLECT_GCC=gcc 
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.9.2/lto-wrapper.exe 
Target: i686-pc-cygwin 
Configured with: /cygdrive/i/szsz/tmpp/gcc/gcc-4.9.2-3.i686/src/gcc-4.9.2/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-4.9.2-3.i686/src/gcc-4.9.2 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --libdir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=i686-pc-cygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libjava --enable-libgcj-sublibs --disable-java-awt --disable-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id 
Thread model: posix gcc version 4.9.2 (GCC) 
COLLECT_GCC_OPTIONS='-o' 'hello.exe' '-v' '-mtune=generic' '-march=i686' /usr/lib/gcc/i686-pc-cygwin/4.9.2/cc1.exe -quiet -v -Dunix -idirafter /usr/lib/gcc/i686-pc-cygwin/4.9.2/../../../../include/w32api -idirafter /usr/lib/gcc/i686-pc-cygwin/4.9.2/../../../../i686-pc-cygwin/lib/../../include/w32api hello.c -quiet -dumpbase hello.c -mtune=generic -march=i686 -auxbase hello -version -o /tmp/cc8W4cOy.s

I've also installed Cygwin on Windows XP that reports this version: CYGWIN_NT-5.1 lt-love6 1.7.35(0.287/5/3) 2015-03-04 12:07 i686 Cygwin

The compile results for hello.c are the same. No executable is made and $?=1 indicating the compile has failed. Also there are no reported errors or warnings. Using -v provides a report similar to the one above.

like image 514
red69 Avatar asked Apr 18 '15 22:04

red69


1 Answers

I had a similar problem (and started a bounty) but have now managed to resolve my own problem by re-installing Cygwin. @CristiFati added a comment to the question asking for clarification of versions but ironically, having added a bounty leaves me with insufficient reputation to be able to reply - so I'll have to answer here instead.

Cygwin setup was used to bring the system up to date and to install the GCC packages (by adding package 'gcc-objc++') as the original Cygwin was installed without GCC support. However, this installation was on a system with multiple users running with restricted privileges. I believe that this interfered with the upgrade and resulted in some files being inaccessible to some users and so the installation of GCC was corrupt.

The behavior was that a successful compilation worked and produced the correct object files but any errors would silently fail, with no output and no error messages (but an exit status of '1').

The solution was to completely remove Cygwin and re-install as my own user. This ensured the permissions were correct so the installation/upgrade could correctly upgrade all files and GCC compilation and error reporting is now working as expected.

To summarize:

  • Incorrect Windows permissions caused package installation issues.
like image 174
Rich Sedman Avatar answered Oct 22 '22 14:10

Rich Sedman