When compiling my program in 32bit using
gcc -m32 program.c -o program
I get the following error fatal error: sys/socket.h: No such file or directory
but with
gcc program.c -o program
it works fine
Is there any workaround for this?
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 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 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
来源:https://stackoverflow.com/questions/16496635/fatal-error-sys-socket-h-no-such-file-or-directory-on-32bit