Reputation: 227
I am using following makefile below:
CC=g++
all: socket.exe
socket.exe: socket.o
g++ socket.o -o socket.exe
socket.o: socket.cpp
g++ -c socket.cpp
When I run make it show error:
socket.cpp: sys/socket.h: no such file or directory.
How to fix it? I am working on Windows.
Upvotes: 13
Views: 77745
Reputation: 137398
<sys/socket.h>
is for UNIX/Linux.
For windows, you use <Winsock2.h>
. You'll also need to link against Ws2_32.lib
and call WSAStartup
to use WinSock.
See also:
socket
function (MSDN)Upvotes: 24