Date: Sat, 9 Sep 2000 20:52:52 +0200 (CEST) From: Ron Scott <ron@tp98.catv.szabinet.hu> To: Vik Nuckchady <vik@mailbox.co.za> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Problem compiling socket program Message-ID: <Pine.BSF.4.21.0009092040300.50547-100000@gep18-5.nyircatv.broadband.hu> In-Reply-To: <200009090717.JAA00679@relay.mailbox.co.za>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <stdio.h>
> #include <sys/types.h>
> #include <sys/socket.h>
>
> 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 <sys/types.h>
#include <sys/socket.h>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0009092040300.50547-100000>
