This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Linking problems with gcc and g++ on Solaris
- From: Russ Allbery <rra at stanford dot edu>
- To: Vinay Kumar <vinkolar at yahoo dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 11 Sep 2002 18:50:08 -0700
- Subject: Re: Linking problems with gcc and g++ on Solaris
- Organization: The Eyrie
- References: <20020912000058.21434.qmail@web40602.mail.yahoo.com>
Vinay Kumar <vinkolar@yahoo.com> writes:
> Im a newbee to the grp and to the domain. Currently, im working on
> Solaris 5.8 and had to write a simple socket program. While trying to
> compile it gives the following errors:
> [vkolar1]socket>g++ server.c
> /var/tmp/ccCe6VUX.o: In function `main':
> /var/tmp/ccCe6VUX.o(.text+0x10): undefined reference
> to `socket'
> /var/tmp/ccCe6VUX.o(.text+0x54): undefined reference
> to `bind'
> /var/tmp/ccCe6VUX.o(.text+0x8c): undefined reference
> to `listen'
> /var/tmp/ccCe6VUX.o(.text+0xb0): undefined reference
> to `accept'
> /var/tmp/ccCe6VUX.o(.text+0xfc): undefined reference
> to `recv'
This isn't really on-topic for this mailing list, which is for GCC
development, not for questions about how to use it. This is a basic C++
programming question.
The answer is that on Solaris the basic socket functions are in different
libraries and you need to add -lsocket -lnsl to link against the socket
and nsl libraries.
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>