Search code examples
cgcccygwin

How To Install GCC On Cygwin


So this C/Python book that I own says to choose gcc, gcc-core and gcc-g++ on the Select Packages window. But I couldn't find any such on the list, so I searched up gcc and selected all these from here, as shown in the picture.

My Select Packages Window with my selections

Finished Installing. Then went to Cygwin and typed in gcc version. It says not found.

Says Not Found

What should I do? Is it because of my version 2.905 as opposed to the book's version of 2.769? Please help.


Solution

  • You have it installed, but you are misunderstanding the usage

    $ gcc --version
    gcc (GCC) 9.3.0
    Copyright (C) 2019 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.
    

    In this way, you are saying the compiler to compile a file called version

    $ gcc version
    gcc: error: version: No such file or directory
    gcc: fatal error: no input files
    compilation terminated.
    

    that gcc can not find, so it reports an error.
    You can also check if a program is available and where is with type

    $ type gcc
    gcc is hashed (/usr/bin/gcc)
    
    $ type g++
    g++ is /usr/bin/g++