Subject: Re: sys/types.h fails to compile under g++
From: Brian Dessent <[email-masked]>
To: [email-masked]
Date: Sat, 31 Jan 2004 11:52:09 -0800

Graham Walsh wrote:
> 
> Hiya, first time using cygwin.... I have a linker error when compiling a
> stock socket app.  All I use is standard calls to socket, bind etc. etc.
> 
> All the symbols usually located in libsocket.so on unix are missing, i.e.
> bind, socket, etc. etc. I am at a loss as to what to link against. If
> anybody knows the compilation and link options I need it would help me out
> completely. I am assuming that the standard cygwin release provides all the
> libs I need to do this type of unix coding on my humble XP box. If I've
> missed anything, please let me know. I am using GCC v3.2 on an XP machine
> with the latest cygwin installation.

You're saying conflicting things here.  In the subject you say that
you're getting compile errors for sys/types.h.  In the body you're
saying you are getting undefined symbol errors from the linker.  Those
two are completely different things.  

If the compiler can't find sys/types.h or gives errors during the
compilation of that file then you have a broken installation.  Run
"cygcheck -c cygwin" to check this, since those header files are
included with the core Cygwin package.  Also, note that every problem
report to this list should be accompanied by a text attachment with the
output of "cygcheck -svr" which would let us diagnose these kinds of
things immediately.  This is spelled out very clearly on the "Problems"
URL on cygwin.com that is at the bottom of every single message on this
list.  If you can't be bothered to follow instructions then don't be
surprised if nobody is eager to help you.

A link error about undefined symbols probably means you're using an
incorrect command line for the compiler.  As Larry said in his reply,
"g++ -o sock sock.cpp" is all you need to compile and run your sample
program.  And, as with him, your code compiles just fine for me with
that command.

To answer your quesion, there is no sockets library with Cygwin, so you
don't need "-lsocket" (nor "-lanything") as you do with Linux.  All of
the socket functions are provided by the core DLL (cygwin1.dll), so
there is no need to do anything special for linking against socket
functions.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/