Thread: Missing some libraries

  1. #1
    Slime Dragoon_42's Avatar
    Join Date
    Feb 2003
    Location
    Vancouver
    Posts
    90

    Missing some libraries

    I'm trying to write a very simple chat program using UDP. I know I need sys/socket.h and netdb.h but my GCC compiler is complaining that it can't find them. Anyone know where I can download them? And after I download them anyone know where I put the libraries so GCC can find them?

  2. #2
    .
    Join Date
    Nov 2003
    Posts
    307
    They go:
    /usr/include/netdb.h
    /usr/include/sys/socket.h

    So, is cpp complining about not finding the header files?
    Or is the linker complaining - you used the word libraries -
    so that means the link phase has errors.

    Post your error message, it may just be that you are not searching for the libraries correctly.

  3. #3
    Slime Dragoon_42's Avatar
    Join Date
    Feb 2003
    Location
    Vancouver
    Posts
    90
    C:\Andy>gcc -Wall -o Server.exe udp_server.c
    udp_server.c:3: socket.h: No such file or directory (ENOENT)

    C:\Andy>gcc -Wall -o Client.exe udpcli.c
    udpcli.c:3: sys/socket.h: No such file or directory (ENOENT)
    udpcli.c:5: netdb.h: No such file or directory (ENOENT)
    udpcli.c:210: warning: `/*' within comment

    C:\Andy>gcc -Wall -o Client.exe udpcli.c
    udpcli.c:3: sys/socket.h: No such file or directory (ENOENT)
    udpcli.c:5: netdb.h: No such file or directory (ENOENT)

    These are my errors. I think my problem is that I'm using Windows (Winsock as opposed to what Linux uses). My code compiles fine on the Linux machine at the University so I'm downloading Red Hat and I'll just switch over. Thanks for your help!

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    OK, which gcc port for windows do you have?
    DJGPP?
    Dev-C++?
    MINGW?
    Cygwin?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    I am not sure, I use linux, but I think when using winsockets, you only need to include winsock32.h or something of that sort, and you need to run WSAStartup at beginning and WSACleanup at the end.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  6. #6
    Slime Dragoon_42's Avatar
    Join Date
    Feb 2003
    Location
    Vancouver
    Posts
    90
    Okay, I'm using DJGPP and I tried including winsock32.h and winsocket32.h to no avail.

  7. #7
    Registered User Seph_31's Avatar
    Join Date
    Nov 2003
    Posts
    24
    i think its just winsock.h
    --Seph

  8. #8
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    correct me if I'm wrong but don't you have to use the -l comand when using librarys with gcc?
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    As far as I know....
    The only port of gcc which supports winsock.h is dev-c++
    The only port of gcc which supports sys/socket.h is cygwin

    DJGPP is aimed at supporting protected mode DOS, and as such has always been v.poor at supporting network programming.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM