This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linking problems with gcc and g++ on Solaris


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]