[haiku-development] Re: gcc, ld and sockets under Haiku

  • From: scott mc <scottmc2@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 19 Oct 2009 03:06:28 +0000

On Mon, Oct 19, 2009 at 2:56 AM, Paulo Estrela <paulojbe@xxxxxxxxx> wrote:
> Hey guys,
>
> This weekend I was doing nothing and took the opportunity to install
> Haiku with GCC4 (not the Hybrid one) on my laptop. The little guy is a
> few years old, a Dell Latitude 110L (CeleronM 1.3GHz, 1.2GB of RAM,
> intel 915 chipset, intel e100 nic and broadcom 57xx wlan card). Except
> for wlan card, everything works perfectly. Congratulations, Haiku
> developers!
>
> After system installation I setup wired network and could realize that
> apparently Haiku misses nslookup, dig, host or any other tool that I
> know to test DNS functionality. I thought, "lets try to build BIND and
> see whats happen". configure script runs fine specifying
> --build=i586-pc-beos, but make prints lots of "undefined reference"
> messages about sockets API functions (socket, connect, listen and
> etc.).
>
> To test this behavior, I decided to build a basic sockets code. I went
> to Wikipedia and found  "Client code in C"
> (http://en.wikipedia.org/wiki/Berkeley_sockets#Client). I tried:  gcc
> tcpclient.c -o tcpclient
>
> It gives me:
>
> ~/Desktop> gcc tcpclient.c -o tcpclient
> /tmp//ccYWJ81I.o: In function `main':
> tcpclient.c:(.text+0x28): undefined reference to `socket'
> tcpclient.c:(.text+0x93): undefined reference to `__inet_pton'
> tcpclient.c:(.text+0x10a): undefined reference to `connect'
> tcpclient.c:(.text+0x149): undefined reference to `shutdown'
> collect2: ld returned 1 exit status
>
> The funny part is that all this exists inside
> /boot/develop/headers/posix/... . Anyone has an idea of how to compile
> this? What am I doing wrong? I tried to add -lsocket parameter, but
> doesn't work.
>
> Sorry about my english and message size!
>
>
> Paulo Estrela
> http://tabugado.com
>
>

unlike BeOS which used -lnet IIRC, Haiku uses -lnetwork when linking
to network related libraries functions.
so change -lsocket to -lnetwork and it should work better for you.

There are some issues with sockets, as the python regression tests point out:
http://ports.haiku-files.org/wiki/PythonRegressionTests
http://dev.haiku-os.org/ticket/4159
-scottmc

Other related posts: