public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Peter A. Friend" <octavian@corp.earthlink.net>
To: Shicheng <S.Tian@shu.ac.uk>
Cc: help-gcc@gnu.org
Subject: Re: socket: Undefined
Date: Mon, 20 Sep 1999 11:04:00 -0000	[thread overview]
Message-ID: <Pine.GSO.4.10.9909201059520.9227-100000@ebola.it.earthlink.net> (raw)
In-Reply-To: <7s5rcm$q40$1@nnrp1.deja.com>

You need to look at the man pages for those functions, where you'll see
stuff like this:

     cc [ flag ... ] file ...  -lsocket -lnsl [ library ... ]
 
     #include <sys/types.h>
     #include <sys/socket.h>
 
On Solaris, you need to include -lsocket and -lnsl for anything that
uses sockets. To make this work, use something like:

gcc *.c -lsocket -lnsl

HTH,

Peter

---
Software Engineer
EarthLink Network

On Mon, 20 Sep 1999, Shicheng wrote:

> I work on SunOS 5.6 platform from a networked NT machine via telnet; and
> I would like to obtain some advice on using the gcc compiler. Under my
> working dir, there are five files: connectsock.c,
> connecttcp.c, connectudp.c, errexit.c and tcpdaytime.c; after issuing
> the commend:
> 
> gcc *.c
> 
> however, I got the following errors:
> 
> "[60]% gcc *.c
> Undefined                      first referenced
> symbol                            in file
> socket                              /var/tmp/cc0heQO31.o
> getprotobyname                      /var/tmp/cc0heQO31.o
> gethostbyname                      /var/tmp/cc0heQO31.o
> getservbyname                      /var/tmp/cc0heQO31.o
> inet_addr                          /var/tmp/cc0heQO31.o
> connect                            /var/tmp/cc0heQO31.o
> ld: fatal: Symbol referencing errors. No output written to a.out"
> 
> In the file connectsock.c, I do include the follwing paths:
> 
> #include "/usr/include/sys/types.h"
> #include "/usr/include/sys/socket.h"
> 
> #include "/usr/include/netinet/in.h"
> #include "/usr/include/netdb.h"
> 
> I even checked all the required files are there under the include dir! I
> had the same errors when using "cc" as well!
> 
> BTW, when trying another simple program which just makes use
> of the #include <stdio.h>, there is no problem/errors at all!
> 
> Thanks for sending me some advice on how to solve this problem.
> 
> Shicheng
> 
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
> 

WARNING: multiple messages have this Message-ID
From: "Peter A. Friend" <octavian@corp.earthlink.net>
To: Shicheng <S.Tian@shu.ac.uk>
Cc: help-gcc@gnu.org
Subject: Re: socket: Undefined
Date: Thu, 30 Sep 1999 23:56:00 -0000	[thread overview]
Message-ID: <Pine.GSO.4.10.9909201059520.9227-100000@ebola.it.earthlink.net> (raw)
Message-ID: <19990930235600.c4iV_PePLJsQiDAON4qWfkEqycnRp5DBpCBvGecDBD0@z> (raw)
In-Reply-To: <7s5rcm$q40$1@nnrp1.deja.com>

You need to look at the man pages for those functions, where you'll see
stuff like this:

     cc [ flag ... ] file ...  -lsocket -lnsl [ library ... ]
 
     #include <sys/types.h>
     #include <sys/socket.h>
 
On Solaris, you need to include -lsocket and -lnsl for anything that
uses sockets. To make this work, use something like:

gcc *.c -lsocket -lnsl

HTH,

Peter

---
Software Engineer
EarthLink Network

On Mon, 20 Sep 1999, Shicheng wrote:

> I work on SunOS 5.6 platform from a networked NT machine via telnet; and
> I would like to obtain some advice on using the gcc compiler. Under my
> working dir, there are five files: connectsock.c,
> connecttcp.c, connectudp.c, errexit.c and tcpdaytime.c; after issuing
> the commend:
> 
> gcc *.c
> 
> however, I got the following errors:
> 
> "[60]% gcc *.c
> Undefined                      first referenced
> symbol                            in file
> socket                              /var/tmp/cc0heQO31.o
> getprotobyname                      /var/tmp/cc0heQO31.o
> gethostbyname                      /var/tmp/cc0heQO31.o
> getservbyname                      /var/tmp/cc0heQO31.o
> inet_addr                          /var/tmp/cc0heQO31.o
> connect                            /var/tmp/cc0heQO31.o
> ld: fatal: Symbol referencing errors. No output written to a.out"
> 
> In the file connectsock.c, I do include the follwing paths:
> 
> #include "/usr/include/sys/types.h"
> #include "/usr/include/sys/socket.h"
> 
> #include "/usr/include/netinet/in.h"
> #include "/usr/include/netdb.h"
> 
> I even checked all the required files are there under the include dir! I
> had the same errors when using "cc" as well!
> 
> BTW, when trying another simple program which just makes use
> of the #include <stdio.h>, there is no problem/errors at all!
> 
> Thanks for sending me some advice on how to solve this problem.
> 
> Shicheng
> 
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
> 

WARNING: multiple messages have this Message-ID
From: "Peter A. Friend" <octavian@corp.earthlink.net>
To: Shicheng <S.Tian@shu.ac.uk>
Cc: help-gcc@gnu.org
Subject: Re: socket: Undefined
Date: Fri, 01 Oct 1999 00:00:00 -0000	[thread overview]
Message-ID: <Pine.GSO.4.10.9909201059520.9227-100000@ebola.it.earthlink.net> (raw)
Message-ID: <19991001000000.ZFCVyAOi77eh_6x1zfzyYtBZHAHSebu8r1aPpHCHA78@z> (raw)
In-Reply-To: <7s5rcm$q40$1@nnrp1.deja.com>

You need to look at the man pages for those functions, where you'll see
stuff like this:

     cc [ flag ... ] file ...  -lsocket -lnsl [ library ... ]
 
     #include <sys/types.h>
     #include <sys/socket.h>
 
On Solaris, you need to include -lsocket and -lnsl for anything that
uses sockets. To make this work, use something like:

gcc *.c -lsocket -lnsl

HTH,

Peter

---
Software Engineer
EarthLink Network

On Mon, 20 Sep 1999, Shicheng wrote:

> I work on SunOS 5.6 platform from a networked NT machine via telnet; and
> I would like to obtain some advice on using the gcc compiler. Under my
> working dir, there are five files: connectsock.c,
> connecttcp.c, connectudp.c, errexit.c and tcpdaytime.c; after issuing
> the commend:
> 
> gcc *.c
> 
> however, I got the following errors:
> 
> "[60]% gcc *.c
> Undefined                      first referenced
> symbol                            in file
> socket                              /var/tmp/cc0heQO31.o
> getprotobyname                      /var/tmp/cc0heQO31.o
> gethostbyname                      /var/tmp/cc0heQO31.o
> getservbyname                      /var/tmp/cc0heQO31.o
> inet_addr                          /var/tmp/cc0heQO31.o
> connect                            /var/tmp/cc0heQO31.o
> ld: fatal: Symbol referencing errors. No output written to a.out"
> 
> In the file connectsock.c, I do include the follwing paths:
> 
> #include "/usr/include/sys/types.h"
> #include "/usr/include/sys/socket.h"
> 
> #include "/usr/include/netinet/in.h"
> #include "/usr/include/netdb.h"
> 
> I even checked all the required files are there under the include dir! I
> had the same errors when using "cc" as well!
> 
> BTW, when trying another simple program which just makes use
> of the #include <stdio.h>, there is no problem/errors at all!
> 
> Thanks for sending me some advice on how to solve this problem.
> 
> Shicheng
> 
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
> 

  reply	other threads:[~1999-09-20 11:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-20 10:57 Shicheng
1999-09-20 11:04 ` Peter A. Friend [this message]
1999-09-30 23:56   ` Peter A. Friend
1999-10-01  0:00   ` Peter A. Friend
1999-09-20 11:05 ` Stephen Frost
1999-09-30 23:56   ` Stephen Frost
1999-10-01  0:00   ` Stephen Frost
1999-09-30 23:56 ` Shicheng
1999-10-01  0:00 ` Shicheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.10.9909201059520.9227-100000@ebola.it.earthlink.net \
    --to=octavian@corp.earthlink.net \
    --cc=S.Tian@shu.ac.uk \
    --cc=help-gcc@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).