windowscygwintermios

I cannot use termios.h in cygwin64


I am making an application where I think I will need to use termios.h But I have windows 10. I installed cygwin64. I type in gcc test.c -o test.exe in the terminal. I still get fatal error: termios.h: No such file or directory #include <termios.h> Is there something I had to do during installation?

The code is just prints hello world but I included termios.h

#include <stdio.h>
#include <termios.h>

int main(){
     printf("Hello World!");

     return 0;
}

Solution

  • Install the missing development package. To find which is, use cygcheck

    $ cygcheck -p usr/include/termios.h
    Found 12 matches for usr/include/termios.h
    cygwin-devel-3.0.7-1 - cygwin-devel: Core development files
    ...
    cygwin-devel-3.2.0-0.1 - cygwin-devel: Core development files
    cygwin-devel-3.2.0-1 - cygwin-devel: Core development files
    ...
    

    You need cygwin-devel

    $ cygcheck -l cygwin-devel |grep termios.h
    /usr/include/termios.h
    /usr/include/machine/termios.h
    /usr/include/sys/termios.h
    

    looking at your example

    $ cat prova.c
    #include <stdio.h>
    #include <termios.h>
    
    int main(){
         printf("Hello World!");
    
         return 0;
    }
    

    and at the compiler

    $ which gcc
    /usr/bin/gcc
    $ gcc --version
    gcc (GCC) 10.2.0
    

    the example builds fine

    $ gcc -Wall prova.c -o prova
    $ ./prova
    Hello World!