public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* socket: Undefined
@ 1999-09-20 10:57 Shicheng
  1999-09-20 11:04 ` Peter A. Friend
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Shicheng @ 1999-09-20 10:57 UTC (permalink / raw)
  To: help-gcc

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: socket: Undefined
  1999-09-20 10:57 socket: Undefined Shicheng
@ 1999-09-20 11:04 ` Peter A. Friend
  1999-09-30 23:56   ` Peter A. Friend
  1999-10-01  0:00   ` Peter A. Friend
  1999-09-20 11:05 ` Stephen Frost
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Peter A. Friend @ 1999-09-20 11:04 UTC (permalink / raw)
  To: Shicheng; +Cc: help-gcc

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.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: socket: Undefined
  1999-09-20 10:57 socket: Undefined Shicheng
  1999-09-20 11:04 ` 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
  3 siblings, 2 replies; 9+ messages in thread
From: Stephen Frost @ 1999-09-20 11:05 UTC (permalink / raw)
  To: Shicheng; +Cc: help-gcc

	Your problem is a linking problem.  You are not linking in the
appropriate libraries.  If you do a 'man socket' you will see that
the first line in the SYNOPSIS is the cc line, which tells you what
libraries you need to link in in order to use the 'socket' function.

SYNOPSIS
     cc  [ flag ... ] file ... -lsocket -lnsl [ library ... ]
     #include <sys/types.h>
     #include <sys/socket.h>

     int socket(int domain, int type, int protocol);

	As you can see, in this case you would need to use 'socket'
and 'nsl'.  So your gcc command would look something like:

gcc -lsocket -lnsl *.c

	You may wish to check the other functions you use to see if
they have other libraries that need to be linked in.

		Stephen

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.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: socket: Undefined
  1999-09-20 11:04 ` Peter A. Friend
@ 1999-09-30 23:56   ` Peter A. Friend
  1999-10-01  0:00   ` Peter A. Friend
  1 sibling, 0 replies; 9+ messages in thread
From: Peter A. Friend @ 1999-09-30 23:56 UTC (permalink / raw)
  To: Shicheng; +Cc: help-gcc

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.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* socket: Undefined
  1999-09-20 10:57 socket: Undefined Shicheng
  1999-09-20 11:04 ` Peter A. Friend
  1999-09-20 11:05 ` Stephen Frost
@ 1999-09-30 23:56 ` Shicheng
  1999-10-01  0:00 ` Shicheng
  3 siblings, 0 replies; 9+ messages in thread
From: Shicheng @ 1999-09-30 23:56 UTC (permalink / raw)
  To: help-gcc

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: socket: Undefined
  1999-09-20 11:05 ` Stephen Frost
@ 1999-09-30 23:56   ` Stephen Frost
  1999-10-01  0:00   ` Stephen Frost
  1 sibling, 0 replies; 9+ messages in thread
From: Stephen Frost @ 1999-09-30 23:56 UTC (permalink / raw)
  To: Shicheng; +Cc: help-gcc

	Your problem is a linking problem.  You are not linking in the
appropriate libraries.  If you do a 'man socket' you will see that
the first line in the SYNOPSIS is the cc line, which tells you what
libraries you need to link in in order to use the 'socket' function.

SYNOPSIS
     cc  [ flag ... ] file ... -lsocket -lnsl [ library ... ]
     #include <sys/types.h>
     #include <sys/socket.h>

     int socket(int domain, int type, int protocol);

	As you can see, in this case you would need to use 'socket'
and 'nsl'.  So your gcc command would look something like:

gcc -lsocket -lnsl *.c

	You may wish to check the other functions you use to see if
they have other libraries that need to be linked in.

		Stephen

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.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: socket: Undefined
  1999-09-20 11:05 ` Stephen Frost
  1999-09-30 23:56   ` Stephen Frost
@ 1999-10-01  0:00   ` Stephen Frost
  1 sibling, 0 replies; 9+ messages in thread
From: Stephen Frost @ 1999-10-01  0:00 UTC (permalink / raw)
  To: Shicheng; +Cc: help-gcc

	Your problem is a linking problem.  You are not linking in the
appropriate libraries.  If you do a 'man socket' you will see that
the first line in the SYNOPSIS is the cc line, which tells you what
libraries you need to link in in order to use the 'socket' function.

SYNOPSIS
     cc  [ flag ... ] file ... -lsocket -lnsl [ library ... ]
     #include <sys/types.h>
     #include <sys/socket.h>

     int socket(int domain, int type, int protocol);

	As you can see, in this case you would need to use 'socket'
and 'nsl'.  So your gcc command would look something like:

gcc -lsocket -lnsl *.c

	You may wish to check the other functions you use to see if
they have other libraries that need to be linked in.

		Stephen

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.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: socket: Undefined
  1999-09-20 11:04 ` Peter A. Friend
  1999-09-30 23:56   ` Peter A. Friend
@ 1999-10-01  0:00   ` Peter A. Friend
  1 sibling, 0 replies; 9+ messages in thread
From: Peter A. Friend @ 1999-10-01  0:00 UTC (permalink / raw)
  To: Shicheng; +Cc: help-gcc

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.
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* socket: Undefined
  1999-09-20 10:57 socket: Undefined Shicheng
                   ` (2 preceding siblings ...)
  1999-09-30 23:56 ` Shicheng
@ 1999-10-01  0:00 ` Shicheng
  3 siblings, 0 replies; 9+ messages in thread
From: Shicheng @ 1999-10-01  0:00 UTC (permalink / raw)
  To: help-gcc

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1999-10-01  0:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-20 10:57 socket: Undefined Shicheng
1999-09-20 11:04 ` Peter A. Friend
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

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).