如何解决我不能在 cygwin64 中使用 termios.h
我正在制作一个我认为需要使用 termios.h
的应用程序,但我有 Windows 10。我安装了 cygwin64。我在终端中输入 gcc test.c -o test.exe
。我仍然收到 Fatal error: termios.h: No such file or directory #include <termios.h>
在安装过程中我必须做的事情吗?
代码只是打印 hello world 但我包含了 termios.h
#include <stdio.h>
#include <termios.h>
int main(){
printf("Hello World!");
return 0;
}
解决方法
取而代之的是:
#include <termios.h>
这个:
#include <sys/termios.h>
安装缺少的开发包。要查找哪个,请使用 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
...
你需要cygwin-devel
$ cygcheck -l cygwin-devel |grep termios.h
/usr/include/termios.h
/usr/include/machine/termios.h
/usr/include/sys/termios.h
看你的例子
$ cat prova.c
#include <stdio.h>
#include <termios.h>
int main(){
printf("Hello World!");
return 0;
}
和编译器
$ which gcc
/usr/bin/gcc
$ gcc --version
gcc (GCC) 10.2.0
示例构建良好
$ gcc -Wall prova.c -o prova
$ ./prova
Hello World!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。