Author Topic: compile winsock  (Read 3332 times)

Offline igi

  • Single posting newcomer
  • *
  • Posts: 7
compile winsock
« on: June 19, 2007, 02:18:31 pm »
i write simple server script using winsock.h, compile it use gcc

gcc -o win win.cpp

output like:

undefined reference to socket....blablabla
undefined reference to bind,........

i hope anyone can post solution

thx..

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: compile winsock
« Reply #1 on: June 19, 2007, 02:42:18 pm »
You didn't specify any library that should be linked with your app.
Be a part of the solution, not a part of the problem.

Offline igi

  • Single posting newcomer
  • *
  • Posts: 7
Re: compile winsock
« Reply #2 on: June 20, 2007, 10:15:20 am »
i tried compile with
gcc -o win win.cpp -lwinsock

is it right ??


Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: compile winsock
« Reply #3 on: June 20, 2007, 03:37:08 pm »
i tried compile with
gcc -o win win.cpp -lwinsock

is it right ??
Well, if it worked, then it would've been right.

Since you're using MinGW's w32api package instead of Microsoft's, though, you'll need to use "-lwsock32" instead. See the .a files in the "lib" subdirectory of your MinGW installation (remember -l stands for "lib").
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)