在Dev C++ 編譯 WinSock 產生以下的error:

  [Linker error] undefined reference to `WSAStartup@8'

  [Linker error] undefined reference to `socket@12'

  [Linker error] undefined reference to `WSACleanup@0'

  [Linker error] undefined reference to `htons@4'

  [Linker error] undefined reference to `bind@12'

  [Linker error] undefined reference to `listen@8'

  [Linker error] undefined reference to `WSAAsyncSelect@16'

  ld returned 1 exit status

***********************************************************

解法:
project -> project options -> in the box saying something like "other linker options" type: 
                                              加入: "-lwsock32"

或是
工具 -> 編譯器選項 -> 在連結器命令列加入以下的命令(打勾)
                                加入 -lwsock32

tool -> compiler options -> add the following commands when calling compiler (checked)
                                           add  -lwsock32

文章標籤
全站熱搜
創作者介紹
創作者 abcdefg 的頭像
abcdefg

seacatcry的部落格

abcdefg 發表在 痞客邦 留言(0) 人氣(0)