Thread: Compiler errors

  1. #1
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972

    Compiler errors

    I was looking at a Winsock tutorial at http://world.std.com/~jimf/papers/so...l#Introduction
    and I copied the example code (figure 1), but when I compile I get errors like:
    c:\dev-c++\myproj\winsock\wins.o(.text+0x36):wins.cpp: undefined reference to `gethostname@8'
    c:\dev-c++\myproj\winsock\wins.o(.text+0x48):wins.cpp: undefined reference to `gethostbyname@4'
    c:\dev-c++\myproj\winsock\wins.o(.text+0x8a):wins.cpp: undefined reference to `htons@4'
    c:\dev-c++\myproj\winsock\wins.o(.text+0xa4):wins.cpp: undefined reference to `socket@12'
    c:\dev-c++\myproj\winsock\wins.o(.text+0xd7):wins.cpp: undefined reference to `bind@12'
    c:\dev-c++\myproj\winsock\wins.o(.text+0xf0):wins.cpp: undefined reference to `closesocket@4'
    c:\dev-c++\myproj\winsock\wins.o(.text+0x10d):wins.cpp: undefined reference to `listen@8'
    C:\DEV-C_~1\LIB\\libmingw32.a(main.o)(.text+0x8e): undefined reference to `WinMain@16'
    I've had errors like this before, but somehow they resolved themselves...not sure what to do...

    Using Dev C++ 4
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    You're missing a library file that you need to link to. I haven't messed with WinSock, but check the tutorial you got it from and look for what lib's you need to link to.

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Thanks...I don't think the tutorial said which library files to link to, but at least I have somewhere to start now.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Its a libray called ws2_32.lib....but as you are using devc++, its called something else...something like "libws2_32.a"....have a look in the lib folder

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. bloodshed compiler errors
    By nerore in forum C++ Programming
    Replies: 5
    Last Post: 04-17-2004, 02:37 PM
  4. How to resolve linking errors?
    By m712 in forum C++ Programming
    Replies: 3
    Last Post: 11-03-2002, 10:17 PM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM