[英]C Socket Programming with CygWin
嗨,我正在尝试使用CygWin用C语言编写一个小的服务器/客户端程序,问题是,Cygwin中的gcc编译器似乎不包含与套接字编程相关的标准头文件。 当尝试编译我的服务器程序时,我得到:
netinet/in.h: No such file or directory
sys/socket.h: No such file or directory
netdb.h: No such file or directory
这三个标头是否位于CygWin环境中的其他位置?
尝试使用-I编译器命令行选项来指定头文件的路径。
我的当地参考资料
-I dir
Add the directory dir to the list of directories to be searched for
header files. Directories named by -I are searched before the
standard system include directories. If the directory dir is a
standard system include directory, the option is ignored to ensure
that the default search order for system directories and the
special treatment of system headers are not defeated .
我也遇到了同样的问题..我经过数小时的搜寻,终于找到了这个...感谢ralph ...
https://ralphexe.wordpress.com/2015/09/09/run-unix-socket-program-in-windows-using-cygwin/
对于套接字命令,您必须在安装时在cygwin中包括某些软件包...(如果已安装,请尝试重新安装...)
在安装过程中:
在“选择软件包”的安装阶段。
展开DEVEL
选择适用于C和C ++的GNU编译器
4.然后单击下一步并完成安装。
现在,尝试使用涉及sys / socket.h的套接字程序。我希望它能起作用... :-) ..
我也有同样的问题。 我决心审查编译选项。
NG:
$ gcc -mno-cygwin -o echo_server.exe echo_server.c
echo_server.c:12:43: sys/socket.h: No such file or directory
echo_server.c:13:24: netinet/in.h: No such file or directory
好:
$ gcc -o echo_server.exe echo_server.c
至少在我的小天鹅上,他们在
/ usr / include / sys和/ usr / include / netinet
我的图书馆失语症困扰了我好几天。 因此,请确保首先使用简单命令配置已安装的库
。/配置
配置完成后,使用以下命令进行构建,安装和检查库
全部 -构建库
安装 -安装库
检查-测试库
doc-通过doxygen生成文档
希望能帮助到你。 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.