Just to help the other viewers out there:
gcc hello.c -o hello.o -lws2_32
undefined reference to `__imp__socket'
解决:
Put the-lws2_32
AFTER the list of object files - GCC searches libraries and object files in the order they appear on the command line.
Just to help the other viewers out there:
gcc hello.c -o hello.o -lws2_32
网址:https://stackoverflow.com/questions/2033608/mingw-linker-error-winsock
https://sourceforge.net/p/mingw-w64/support-requests/9/
经典回答:
It appears i neglected to use -lws2_32. The undefined references for socket functions are gone.
However the undefined references for pthread are back. :(
Put the -lws2_32
AFTER the list of object files - GCC searches libraries and object files in the order they appear on the command line.
Just to help the other viewers out there:
gcc hello.c -o hello.o -lws2_32