From owner-freebsd-questions Sat Sep 9 11:54:59 2000 Delivered-To: freebsd-questions@freebsd.org Received: from gep18-5.nyircatv.broadband.hu (gep18-5.nyircatv.broadband.hu [195.184.160.117]) by hub.freebsd.org (Postfix) with ESMTP id B9C7637B422 for ; Sat, 9 Sep 2000 11:54:55 -0700 (PDT) Received: (from witch@localhost) by gep18-5.nyircatv.broadband.hu (8.9.3/8.9.3) id UAA50811; Sat, 9 Sep 2000 20:52:52 +0200 (CEST) (envelope-from witch) Date: Sat, 9 Sep 2000 20:52:52 +0200 (CEST) From: Ron Scott Reply-To: Ron Scott To: Vik Nuckchady Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Problem compiling socket program In-Reply-To: <200009090717.JAA00679@relay.mailbox.co.za> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Today Vik Nuckchady wrote: > Hello, > I am trying to compile a very simple program but it fails every > time with the following errors: > > /* MAKE INSTRUCTIONS */ > cc client.c -o client.o > cc -Lnsl -Lsocket client.o -o client > /* ERRORS STARTS HERE */ > client.o: In function `_init': > client.o(.init+0x0): multiple definition of `_init' > /usr/lib/crti.o(.init+0x0): first defined here [...] > > The program contains the following : > > #include > #include > #include > > void main() > { > int sock_d = socket(PF_INET,SOCK_STREAM,0); > } > > Thanks in advance for any support. Sorry, but this isn't a C program. main() returns int. Try the following: #include #include int main(void) { int fd = socket(AF_INET, SOCK_STREAM, 0); return 0; } And compile with: cc -o foo foo.c You don't need (and have) the nsl/socket library. socket() is a system call in *BSD and a library call in Solaris. -Ron > > Cheers > Vik > _______________________________________________________________ > http://www.webmail.co.za the South-African free email service > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > > -- UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things. (Doug Gwyn) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message