user3424840
user3424840

Reputation: 227

makefile error: sys/socket.h no such file or directory under Windows

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

Answers (1)

Jonathon Reinhart
Jonathon Reinhart

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:

Upvotes: 24

Related Questions