[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Library path with AC_CHECK_LIB

From: moseley
Subject: Re: Library path with AC_CHECK_LIB
Date: Wed, 11 Jun 2003 08:01:39 -0700
User-agent: Mutt/1.5.4i

Hi, I'd like to ask about this again, as I'm waiting to release on this 

The problem is that configure[1] is finding[2] libz and adding it to my
link line[3] but when linking libz is not found.

libz is in /usr/local/lib, but that is not a compiled in path for ld.

  %/usr/ccs/bin/ld -V
  ld: Software Generation Utilities - Solaris/ELF (3.0)

This is on Solaris 2.6.  
# Generated by GNU Autoconf 2.57.

I'm wondering if this is just a single broken machine or if we will have 
problems on other Solaris machines.

If I grab conftest.c out of configure and manually compile:

%gcc -o conftest -g -O2 conftest.c -lz  -lm || echo "NO!!"
%./conftest ./conftest: fatal: open failed: No such file or directory

%ldd conftest =>       (file not found) =>     /usr/lib/ =>     /usr/lib/ =>    /usr/lib/

Is that expected that gcc wouldn't report an error back to configure?

I don't understand what gcc uses to link, but it seems like gcc thinks 
/usr/local/lib is a standard search path.  But when /usr/ccs/bin/ld is 
used to link[3] /usr/local/lib is NOT a standard search path.

Is there something that needs to be done on this Solaris machine to get
the standard search paths in sync?  A global LD_LIBRARY_PATH is one way,
but there seems to be arguments against that.

I suppose that check for solaris in [1] below is there to add -R.

%truss -f -t open gcc -o conftest -g -O2 conftest.c -lz -lm
26700:  open("/usr/ccs/bin/", O_RDONLY)          Err#2 ENOENT
26700:  open("/usr/ccs/bin/libz.a", O_RDONLY)           Err#2 ENOENT
26700:  open("/usr/ccs/lib/", O_RDONLY)          Err#2 ENOENT
26700:  open("/usr/ccs/lib/libz.a", O_RDONLY)           Err#2 ENOENT
26700:  open("/usr/local/lib/", O_RDONLY)        = 7

Now try with Solaris' ld:

%truss -f -t open /usr/ccs/bin/ld -o conftest conftest.o -lz -lm -lc
28657:  open("/dev/zero", O_RDONLY)                     = 3
28657:  open("/usr/lib/", O_RDONLY)            = 4
28657:  open("/usr/lib/", O_RDONLY)           = 4
28657:  open("/usr/platform/SUNW,Ultra-Enterprise/lib/", O_RDONLY) 
= 4
28657:  open("conftest.o", O_RDONLY)                    = 3
28657:  open("/usr/lib/", O_RDONLY)           = 3
28657:  open("/dev/zero", O_RDWR)                       = 3
28657:  open("/usr/lib/", O_RDONLY)          = 3
28657:  open("/usr/lib/", O_RDONLY)       = 3
28657:  open("/dev/zero", O_RDONLY)                     = 3
28657:  open("conftest", O_RDWR|O_CREAT|O_TRUNC, 0777)  = 3
28657:  open("conftest.o", O_RDONLY)                    = 4
28657:  open("/usr/ccs/lib/", O_RDONLY)          Err#2 ENOENT
28657:  open("/usr/ccs/lib/libz.a", O_RDONLY)           Err#2 ENOENT
28657:  open("/usr/lib/", O_RDONLY)              Err#2 ENOENT
28657:  open("/usr/lib/libz.a", O_RDONLY)               Err#2 ENOENT
ld: fatal: library -lz: not found

BTW - Is there a better way to optionally include a library than [1] 


[1] ---------

(this is an updated version from my previous post)
Autoconf 2.57

dnl Checks for zlib library. -- from libxml2

[  --with-zlib[[=DIR]]       use libz in DIR],[
  if test "$withval" != "no" -a "$withval" != "yes"; then
    CPPFLAGS="${CPPFLAGS} -I$withval/include"
    LDFLAGS="${LDFLAGS} -L$withval/lib"
if test "$with_zlib" = "no"; then   
    echo "Disabling compression support"
        AC_CHECK_LIB(z, gzread,[
            AC_DEFINE(HAVE_ZLIB,[],[Do we have zlib])
            if test "x${Z_DIR}" != "x"; then
                Z_LIBS="-L${Z_DIR}/lib -lz"
                [case ${host} in
                        Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"



[2] ------------

configure:11574: checking zlib.h usability
configure:11587: gcc -c -g -O2  conftest.c >&5
configure:11590: $? = 0
configure:11593: test -s conftest.o
configure:11596: $? = 0
configure:11606: result: yes
configure:11610: checking zlib.h presence
configure:11621: gcc -E  conftest.c
configure:11627: $? = 0
configure:11646: result: yes
configure:11682: checking for zlib.h
configure:11689: result: yes
configure:11697: checking for gzread in -lz
configure:11728: gcc -o conftest -g -O2   conftest.c -lz  -lm  >&5
configure:11731: $? = 0
configure:11734: test -s conftest
configure:11737: $? = 0
configure:11749: result: yes

[3] -------------

/usr/ccs/bin/ld -G -h -o .libs/  search.lo 
swish2.lo swish_words.lo proplimit.lo rank.lo db_read.lo result_sort.lo hash.lo 
compress.lo db_native.lo ramdisk.lo check.lo error.lo list.lo mem.lo 
swstring.lo docprop.lo metanames.lo headers.lo swish_qsort.lo date_time.lo 
double_metaphone.lo stemmer.lo soundex.lo -z allextract 
replace/.libs/ snowball/.libs/ -z defaultextract  
-lz -lm -lc 
ld: fatal: library -lz: not found

Bill Moseley

reply via email to

[Prev in Thread] Current Thread [Next in Thread]