6

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.

8
  • 1
    Are there any errors when you run gcc, or does it return a non-zero return code? Does this happen for every source file, or just for the hello.c example you gave? Do you use any libraries, if so which ones?
    – Thayne
    Commented Apr 18, 2015 at 23:03
  • If you are installing Cygwin NT-6.1, that's not the correct installation and I don't even know where you got that. Are you using the installer from the cygwin web site? Also, I don't recall if cygwin executables run as a .exe or whether it must be a .out
    – Rob
    Commented Apr 19, 2015 at 2:15
  • @Rob: Cygwin executables are named with a .exe suffix. Cygwin lets a file with a .exe suffix be referred to by its base name; for example hello and hello.exe are the same file. Commented May 11, 2015 at 0:52
  • I believe the name "NT-6.1" refers to Windows 7. There is no single version number for Cygwin. The temporary file /tmp/ccr6nMlO.s is normal; that's the assembly language file that's assembled to a .o file, which is then linked into an executable. Does the gcc command produce any messages? Is there a file named hello.exe in the current directory? Commented May 11, 2015 at 1:01
  • "Have the compile flags or their syntax changed?" No. Something is wrong with your Cygwin and/or gcc configuration. Try reinstalling gcc, and remember that "NT-6.1" is not a Cygwin version number. Commented May 11, 2015 at 15:34

4 Answers 4

3

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.
1

I am not sure if you are only interested in having a working system (in which case you could simply reinstall Cygwin, possibly a newer version), or in being certain about forensics, i.e., determining the cause of your problem.

For the second objective, one thing you could do is isolating the 3 phases of going from hello.c to hello.exe:

  1. Preprocessing (using -v for verbosity)

    gcc -E hello.c -v -o hello.i
    
  2. Compiling

    gcc -c hello.c -v -o hello.o
    

(or you could also compile hello.i)

  1. Linking

    gcc hello.o -v -o hello.exe
    

and checking which of the three fails first. That may give you a clue on possible sources of failure.

PS: I cannot reproduce your problem with

$ uname -a
MSYS_NT-10.0-WOW P522806 2.11.2(0.329/5/3) 2018-11-26 08:59 i686 Msys

$ gcc --version
gcc.exe (Rev3, Built by MSYS2 project) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0

As per I've used, a simple GCC command in Cygwin terminal as

$ gcc filename.c

produces output file "a". You can run it as follows:

$ ./a

Hope it helps.

8
  • This is the version I have. It came from a cygwin mirror. $ uname -a CYGWIN_NT-6.1-WOW Gary-PC 1.7.35(0.287/5/3) 2015-03-04 12:07 i686 Cygwin
    – red69
    Commented May 10, 2015 at 23:48
  • gcc filename.c creates a file called a.exe. That file can also be referred to as a. The -o option specifies the name of the output file. The command given in the question should work. Commented May 11, 2015 at 0:55
  • Nothing is created in the current directory. Not a.out, a.exe, or anything by any name.
    – red69
    Commented May 11, 2015 at 1:44
  • I get nothing and the return code is 1 indicating gcc failed.
    – red69
    Commented May 11, 2015 at 2:02
  • @red69: If you want me to see a comment, mention my name following an @ sign. Without that, I probably won't be notified. I only saw this because I happened to check the question again. If you include the output of gcc -v formatted as code (copy-and-paste and use the {} icon), we might be able to help. Commented May 11, 2015 at 15:33
0

I have faced similar issue. This problem is probably due to using incompatible versions of the cygwin DLL. Search for cygwin1.dll using the Windows Start->Find/Search facility and delete all but the most recent version. The most recent version should reside in x:\cygwin\bin, where 'x' is the drive on which you have installed the cygwin distribution. Rebooting is also suggested if you are unable to find another cygwin DLL.

Not the answer you're looking for? Browse other questions tagged or ask your own question.