Thread: Winsock compilation errors

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    Winsock compilation errors

    I am new to winsock and went through a tutorial and made a program similar to the one in the tutorial. When compiling no syntax errors or anything but it came up with a list of linking errors. I don't understand this because the linking errors are about the basic commands like WSAStartup, WSACleanup,accept,bind,etc. Here are the errors:
    Code:
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x127):winsock.cpp: undefined reference to `WSAStartup@8'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x138):winsock.cpp: undefined reference to `socket@12'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x164):winsock.cpp: undefined reference to `WSACleanup@0'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x18c):winsock.cpp: undefined reference to `htons@4'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x1b0):winsock.cpp: undefined reference to `bind@12'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x1dc):winsock.cpp: undefined reference to `WSACleanup@0'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x1f4):winsock.cpp: undefined reference to `listen@8'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x220):winsock.cpp: undefined reference to `WSACleanup@0'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x237):winsock.cpp: undefined reference to `accept@12'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x263):winsock.cpp: undefined reference to `WSACleanup@0'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x27b):winsock.cpp: undefined reference to `closesocket@4'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x28d):winsock.cpp: undefined reference to `closesocket@4'
    C:\WINDOWS\TEMP\ccz22ggb.o(.text+0x295):winsock.cpp: undefined reference to `WSACleanup@0'
    I included windows.h, winsock.h, and stdio.h. Do I need to link a library as well or why are these errors coming up?
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  2. #2
    He's trying.
    Join Date
    Apr 2005
    Location
    Missouri, US
    Posts
    70
    With Dev-C++, I need to link these two libraries:

    /Dev-Cpp/lib/libws2_32.a
    /Dev-Cpp/lib/libwsock32.a

    Strangely, my program works fine without #including winsock2.h...hm.

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Thanks, I had a feeling I needed to link some libraries.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. winsock linking problems
    By Calef13 in forum Windows Programming
    Replies: 2
    Last Post: 08-29-2007, 08:54 AM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Header File Errors...
    By Junior89 in forum C++ Programming
    Replies: 5
    Last Post: 07-08-2007, 12:28 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM