分类: 项目管理
2010-08-06 19:03:38
undefined reference to
hxzon:缺少libwsock32.a 。在 Dev-Cpp\lib 和 mingw\lib 下。
==================
我用DEVCPP4.9.7.8编译一SOCKET程序时出现如下编译连接错误:
Compiler: Default compiler
Building Makefile: "F:\sock\Makefile.win"
Executing make...
make.exe -f "F:\sock\Makefile.win" all
gcc.exe server.o -o "Server.exe" -L"C:/Dev-Cpp/lib"
server.o(.text+0x2d7):server.c: undefined reference to `recv@16'
server.o(.text+0x301):server.c: undefined reference to `WSAGetLastError@0'
server.o(.text+0x395):server.c: undefined reference to `send@16'
server.o(.text+0x3bd):server.c: undefined reference to `WSAGetLastError@0'
server.o(.text+0x4b5):server.c: undefined reference to `WSAStartup@8'
server.o(.text+0x4e6):server.c: undefined reference to `socket@12'
server.o(.text+0x502):server.c: undefined reference to `WSAGetLastError@0'
server.o(.text+0x532):server.c: undefined reference to `inet_addr@4'
server.o(.text+0x55a):server.c: undefined reference to `htonl@4'
server.o(.text+0x57e):server.c: undefined reference to `htons@4'
server.o(.text+0x5a2):server.c: undefined reference to `bind@12'
server.o(.text+0x5b4):server.c: undefined reference to `WSAGetLastError@0'
server.o(.text+0x5e1):server.c: undefined reference to `listen@8'
server.o(.text+0x613):server.c: undefined reference to `accept@12'
server.o(.text+0x62f):server.c: undefined reference to `WSAGetLastError@0'
server.o(.text+0x657):server.c: undefined reference to `ntohs@4'
server.o(.text+0x66f):server.c: undefined reference to `inet_ntoa@4'
server.o(.text+0x6fb):server.c: undefined reference to `closesocket@4'
server.o(.text+0x703):server.c: undefined reference to `WSACleanup@0'
make.exe: *** [Server.exe] Error 1
Execution terminated
这是什么原因引起的?
---------------------------
先找到:菜单 Project->project Options ->中的"Linker Options/Optonal Libs or Obeject files ",
点击右边的"Add Library or Object" --> 在你的..\lib目录中找到:"libwsock32.a",选中,点击"打开"-->返回后再按"ok",
重新编译链接即可.