-1

I'm still quite new to programming. I'm trying to make a hangman game with a server and client using winsock.h, but i can't seem to make it compile. I get the following errors when trying to compile it from the cmd window, even though I already modified the compiler linker setting (in codeblocks):

C:\Users\USER\Documents\Maestria\Computacion\prueva2>gcc cliente.c -o client.exe
undefined reference to `WSAStartup@8'
undefined reference to `socket@12'
undefined reference to `htons@4'
undefined reference to `inet_addr@4'
undefined reference to `connect@12'
undefined reference to `closesocket@4'
undefined reference to `send@16'
undefined reference to `recv@16'
undefined reference to `closesocket@4'
undefined reference to `WSACleanup@0'
collect2.exe: error: ld returned 1 exit status

Does anybody know what might be the issue?

Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696

1 Answers1

0

You need to add the Ws2_32 library file to your project. Go to 'Project build options' -> 'Linker settings' tab -> click 'Add' button and write Ws2_32.

enter image description here

Now everything should work.

Sergio
  • 813
  • 8
  • 26