1

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;
}
dareesome
  • 133
  • 1
  • 7

2 Answers2

2

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!
matzeri
  • 8,062
  • 2
  • 15
  • 16
  • Did the second command, then I tried ``/usr/include/termios.h`` No such file or directory – dareesome May 04 '21 at 12:47
  • to install any package use setup. Cygcheck is for checking AFTER the package is installed – matzeri May 04 '21 at 13:13
  • Alright, sorry. I installed the package and ran ``cygcheck -l cygwin-devel |grep termios.h`` It found it in the directories that you showed but when I run ``gcc test.c -o text.exe`` I get the same error – dareesome May 04 '21 at 15:07
  • please show the code and how you are compiling it – matzeri May 04 '21 at 16:23
  • Added the code, just hello world but I included ``termios.h`` I open cygwin64 and type in ``gcc test.c -o text.exe`` after going to the directory where the test file is – dareesome May 04 '21 at 18:39
  • Didnt see the edit, sorry. Thanks dude, I figured out I was using an outdated version of gcc. Thanks! – dareesome May 04 '21 at 23:35
-1

Instead of this:

#include <termios.h>

This:

#include <sys/termios.h>

selbie
  • 100,020
  • 15
  • 103
  • 173