Thread: GCC - Strange networking functions error.

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    54

    GCC - Strange networking functions error.

    I get the following output when I run gcc compilter. These are my includes:
    winsock2.h stdio.h
    Does anyone know why this is happening? This stuff comes immediately after the errors and warnings that normally occur. I'm using Win2k operating system, with the latest version of GCC compiler.

    \Temp/cckLaaaa.o(.text+0x38a):ylogin.c: undefined reference to `WSAStartup@8'
    \Temp/cckLaaaa.o(.text+0x50e):ylogin.c: undefined reference to `socket@12'
    \Temp/cckLaaaa.o(.text+0x52a):ylogin.c: undefined reference to `WSAGetLastError@0
    \Temp/cckLaaaa.o(.text+0x53f):ylogin.c: undefined reference to `WSACleanup@0'
    \Temp/cckLaaaa.o(.text+0x552):ylogin.c: undefined reference to `WSAGetLastError@0
    \Temp/cckLaaaa.o(.text+0x567):ylogin.c: undefined reference to `WSACleanup@0'
    \Temp/cckLaaaa.o(.text+0x588):ylogin.c: undefined reference to `socket@12'
    \Temp/cckLaaaa.o(.text+0x5a6):ylogin.c: undefined reference to `inet_addr@4'
    \Temp/cckLaaaa.o(.text+0x5bb):ylogin.c: undefined reference to `htons@4'
    \Temp/cckLaaaa.o(.text+0x5da):ylogin.c: undefined reference to `inet_addr@4'
    \Temp/cckLaaaa.o(.text+0x5ef):ylogin.c: undefined reference to `htons@4'
    \Temp/cckLaaaa.o(.text+0x61d):ylogin.c: undefined reference to `connect@12'
    \Temp/cckLaaaa.o(.text+0x636):ylogin.c: undefined reference to `WSACleanup@0'
    \Temp/cckLaaaa.o(.text+0x65b):ylogin.c: undefined reference to `connect@12'
    \Temp/cckLaaaa.o(.text+0x674):ylogin.c: undefined reference to `WSACleanup@0'
    \Temp/cckLaaaa.o(.text+0x6b8):ylogin.c: undefined reference to `send@16'
    \Temp/cckLaaaa.o(.text+0x6e9):ylogin.c: undefined reference to `recv@16'
    \Temp/cckLaaaa.o(.text+0x711):ylogin.c: undefined reference to `closesocket@4'
    \Temp/cckLaaaa.o(.text+0x745):ylogin.c: undefined reference to `recv@16'
    \Temp/cckLaaaa.o(.text+0x7ba):ylogin.c: undefined reference to `send@16'
    \Temp/cckLaaaa.o(.text+0x7ef):ylogin.c: undefined reference to `recv@16'
    \Temp/cckLaaaa.o(.text+0xb35):ylogin.c: undefined reference to `send@16'
    \Temp/cckLaaaa.o(.text+0xb80):ylogin.c: undefined reference to `recv@16'
    \Temp/cckLaaaa.o(.text+0xc91):ylogin.c: undefined reference to `recv@16'
    \Temp/cckLaaaa.o(.text+0x13a4):ylogin.c: undefined reference to `send@16'
    \Temp/cckLaaaa.o(.text+0x13fc):ylogin.c: undefined reference to `recv@16'

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Those errors look like exactly what you should expect if winsock was not really being included. Double check that the library is linked correctly and all that. As far as specifics go, I'm useless in this particular case, as I didn't even know that gcc was available for Windows other than in the case of MinGW or cygwin.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    54
    Quote Originally Posted by sean_mackrory
    Those errors look like exactly what you should expect if winsock was not really being included. Double check that the library is linked correctly and all that. As far as specifics go, I'm useless in this particular case, as I didn't even know that gcc was available for Windows other than in the case of MinGW or cygwin.
    im running it through the gcc that came with dev c++, just set the path and it can be run from the command line

  4. #4
    return 0;
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    89
    Did you link the winsock library? I don't know how to do it from the command line, but in Dev-C++ it can be done like this:

    Project => Project options => Parameters => Add library or object

    You should then add "libws2_32.a" to your project (I have it located at "C:\Program Files\Dev-Cpp\lib")

    [edit]
    I searched a little for linking from the command line, and this should do the trick:

    gcc yourfile.c -lws2_32 -o program.exe

    The -lNAME option tells the linker to look for "libNAME.a" in the default library directory
    [/edit]
    Last edited by Snip; 04-05-2005 at 12:04 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  2. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  3. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  4. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM