当使用 32 位编译我的程序时
gcc -m32 program.c -o program
我收到以下错误致命错误:sys/socket.h:没有这样的文件或目录
但与
gcc program.c -o program
效果很好
有什么解决方法吗?
我个人的类似问题解决如下:
顺便说一句,我正在使用 cygwin。
此错误背后的原因是尝试在窗口环境中编译 unix c 套接字示例。
如果你想使用Windows,我认为你应该安装cygwin,其中包含编译c程序所需的所有库;“gcc是用于生成Your_program_in_exe的库”。
然后开始编译服务器server.followthis了解套接字基础知识的教程。
您应该有一个客户端和一个服务器程序。然后转到(使用 cd 命令)到存储代码的目录并执行命令:
1- gcc socket-Server.c -o 服务器为服务器生成执行文件。
这将生成服务器程序文件将允许您使用./服务器.exe在您的 PC 上运行服务器。如果您的文件中没有错误,您的目录中应该有 .exe 文件。
2- gcc socket-client.c -o client to generate the execution file for the client. This will generate the file client.exe file which allows you to execute the client.if there is no error u should have the client.exe together with ur server.exe in the file directory.
the screen capture below shows the commands i used and the basic output
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)