致命错误:sys/socket.h:32 位上没有这样的文件或目录 [英] fatal error: sys/socket.h: No such file or directory on 32bit

查看:75
本文介绍了致命错误:sys/socket.h:32 位上没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用

gcc -m32 program.c -o program

我收到以下错误致命错误:sys/socket.h: No such file or directory

I get the following error fatal error: sys/socket.h: No such file or directory

但与

gcc program.c -o program

效果很好

有什么解决方法吗?

推荐答案

我个人的类似问题解决如下:顺便说一下,我正在使用 cygwin.此错误背后的原因是试图在窗口环境中编译 unix c 套接字示例.如果你想使用windows,我认为你应该安装cygwin,其中包含编译c程序所需的所有库;gcc是用于生成Your_program_in_exe的库".然后开始编译服务器 server.follow 这个教程来了解套接字的基础知识.您应该有一个客户端和一个服务器程序.然后(使用 cd 命令)到您存储代码的目录并执行命令:

my personal similar problem was solved as below: by the way I am using cygwin. The reason behind this error is trying to compile a unix c socket example in a window environment. If you want to use windows, I think you should have cygwin installed with all the libraries needed for compiling c programs ;"gcc is the one used for generated Your_program_in_exe ". Then start with compiling the server the server.follow this tutorial to understand about the basic of sockets. You should have a client and a server programs.then go(using cd command) to the directory where you stored your code and perform the commands:

1- gcc socket-Server.c -o server 为服务器生成执行文件.这将生成 server.exe 文件,该文件将允许您使用 ./server.exe 在您的 PC 上运行服务器.如果您的文件中没有错误,您应该在您的目录中有 .exe 文件.

1- gcc socket-Server.c -o server to generate the execution file for the server. this will generate server.exe file which will allow you to use ./server.exe to run the sever on your PC.if there is no error in your file you should have the .exe file in the your directory.

2- gcc socket-client.c -o client 为客户端生成执行文件.这将生成文件 client.exe 文件,它允许您执行客户端.如果没有错误,您应该将 client.exe 与您的 服务器一起使用.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

这篇关于致命错误:sys/socket.h:32 位上没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆