autoconf, SunOS, nsl library

autoconf, SunOS, nsl library

Post by Jem Berke » Sat, 14 Sep 2002 13:21:06



I used autoconf+automake with a little program I'm working on (lang:C).
There's really no network code except for gethostname and gethostbyname,
the latter which causes some trouble on SunOS (unresolved symbol) but no
other *nix I've tried yet.

When I compile manually on SunOS I use -lnsl (NSL lib). I thought
autoconf/automake was supposed to automate detection of just such things?
Or not? Is this a 'special case' I should add into my configure.ac ? So far
I have these relevant references in configure.ac

AC_CHECK_HEADERS(... netdb.h ...)
AC_CHECK_FUNCS(gethostname)

But apparently that's not enough. Any suggestions?

--
Jem Berkes
Student IEEE (Canada)

http://www.pc-tools.net/
Windows, Linux & UNIX software

 
 
 

autoconf, SunOS, nsl library

Post by Steve Ke » Mon, 16 Sep 2002 01:14:42



> When I compile manually on SunOS I use -lnsl (NSL lib). I thought
> autoconf/automake was supposed to automate detection of just such things?
> Or not?

  The code you show will let autoconf detect whether you have the headers
 and functions defined - but it doesn't do the job of updating your build
 command to include the correct libraries in the link stage.

  What you've done is tested that you have the headers, so in your code
 you can use:

#ifdef HAVE_NETDB
#include <netdb.h>
#endif

   To actually include the nsl library, conditionally, you should make use
 of the macro from the GNU Autoconf archive:

   http://www.gnu.org/software/ac-archive/Miscellaneous/etr_socket_nsl.html

   Include that code in your configure.in, then add a call to it:

ETR_SOCKET_NSL

   That will then do the linking properly.  (Notice that the macro as
 presented only updates the flags for gcc, not g++...)

Steve
----
# GNU MP3 /OGG Streamer
http://www.gnump3d.org/

 
 
 

autoconf, SunOS, nsl library

Post by Jem Berke » Mon, 16 Sep 2002 15:06:41


Quote:>> When I compile manually on SunOS I use -lnsl (NSL lib). I thought
>> autoconf/automake was supposed to automate detection of just such
>> things? Or not?

>   What you've done is tested that you have the headers, so in your
>   code
>  you can use:

OK, I discovered that config.h file so now I better understand how to use
that in my application.

Quote:>    To actually include the nsl library, conditionally, you should make
>    use
>  of the macro from the GNU Autoconf archive:
> ETR_SOCKET_NSL

I checked that out, but I also found another way that seems to do it. The
only network function call I use is gethostbyname, so:

AC_CHECK_LIB(nsl, gethostbyname)

This seems to work on my Linux system and the SunOS systems. Wish I had
more *nix systems to test on!!

--
Jem Berkes
Student IEEE (Canada)

http://www.pc-tools.net/
Windows, Linux & UNIX software

 
 
 

autoconf, SunOS, nsl library

Post by shadow » Tue, 24 Sep 2002 21:34:44



> AC_CHECK_LIB(nsl, gethostbyname)

> This seems to work on my Linux system and the SunOS systems. Wish I had
> more *nix systems to test on!!

It works because gethostbyname is linked it via the C library and
adding -lnsl doesn't make a difference. You need to test it first
_without_ -lnsl and then with to find out if the nsl library is
required. Or at least this is one of the ways to do it.

--
Thamer Al-Harbash    http://www.whitefang.com/

 
 
 

1. SunOS 4.1.x libraries on Solaris 2.x (sunos 5.x)

Hi,
      I have pre-built third party libraries from sunos 4.1.x. They were
built on that version of the OS.
Now, when I link new programs on sunos 5.x and above, Iam unable to link
these old libs, because the linker complains about the format of these
old libs. Is there a way to make them work on sunos 5.x and above ?
I have no sources for these third party libs.

Second, iam able to build executables on sunos 4.1.x successfully with
these old libs and the the binaries work nicely on sunos 4.1.x, but
crash on sunos 5.x and above. Is there a solution other than getting the
latest version of these libs ?

TIA,
-RSN

2. How to Fix this Bug?

3. finding libraries with autoconf

4. X11/XDM - Server hangs after second logout ...

5. autoconf/automake and libraries

6. Video card - which one should I buy?

7. Problems with autoconf and ELF libraries?

8. Off topic, pero interesante...

9. Integrating a library using autoconf and automake

10. Autoconf, automake and shared library objects

11. Autoconf Newbie: How to check and seek an installed library

12. Autoconf, automake and shared library objects

13. problem: Assertion failed: MUTEX_HELD(&ti_userlock), file nsl/utility.c