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

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

问题描述

在使用编译我的程序在32位

When compiling my program in 32bit using

gcc -m32 program.c -o program

我收到以下错误致命错误:SYS / socket.h中:没有这样的文件或目录

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

gcc program.c -o program

正常工作

有没有办法解决这个?

推荐答案

我个人的类似的问题解决了,如下:
顺便说一句,我使用的cygwin。
这个错误背后的原因是试图编译在窗口环境中的UNIX下的C座的例子。
如果您希望使用Windows,我认为你应该有需要编译C程序的所有库安装了Cygwin,GCC是用于生成Your_program_in_exe之一。
然后编译服务器server.follow的本教程了解有关插座的基本。
你应该有一个客户端和服务器programs.then走(用cd命令)到存储您的code中的目录和执行命令:

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插槽Server.c -o服务器以生成服务器的执行文件。
这将产生的 SERVER.EXE 文件,该文件将允许您使用 ./ SERVER.EXE 以运行在你的断绝PC.if没有在文件中没有错误,你应该在该目录中的.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插座client.c -o客户以生成客户端的执行文件。这将生成文件的 client.exe 文件,它可以让你执行client.if没有错误ü应具备的 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天全站免登陆