Subject: Linker (ld) seems to ignore certain LDFLAGS during configure
To: None <tech-pkg@NetBSD.org>
From: Eric Boutilier <Eric.Boutilier@Sun.COM>
List: tech-pkg
Date: 02/18/2005 15:09:42
I'm perplexed by a problem where a configure script is not able to
find a library. The error message is:

  ld: fatal: library -lcrypto: not found

As a result, the package (curl) gets built w/out SSL support.

I'm trying to make the build find the libcrypto.so library which,
on Solaris 10, resides in /usr/sfw/lib.

I've tried to troubleshoot the problem but I'm still stumped.  The
LDFLAGS are set properly (see below) to include:
   -L/usr/sfw/lib -Wl,-R/usr/sfw/lib

And in order to confirm that this setup should work, I copied the
compile command and flags verbatim out of config.log (copied below)
and ran it manually from a command line. When I do that, it
compiles (finds libcrypto.so) just fine.

Very weird... at least for me. :-/

Below is the snippet from config.log that contains the gcc command
line, the ld error messages, and the program (conftest.c) that it's
trying to compile.

It's using the pkgsrc gcc.

Thanks in advance for any help!

Eric

---------------------

configure:24544: gcc -o conftest -O -I/usr/include -I/usr/pkg/include -I/usr/sfw/include   -I/usr/include -I/usr/pkg/include -I/usr/sfw/include -I/usr/sfw/include/openssl -I/usr/sfw/include -L/usr/sfw/lib -L/usr/sfw/lib -Wl,-R/usr/sfw/lib  -L/usr/pkg/gcc3/lib/gcc-lib/i386-sun-solaris2/3.3.5 -Wl,-R/usr/pkg/gcc3/lib/gcc-lib/i386-sun-solaris2/3.3.5 -L/usr/pkg/gcc3/lib -Wl, -R/usr/pkg/gcc3/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/sfw/lib conftest.c -lcrypto  -lsocket -lnsl >&5
ld: fatal: library -lcrypto: not found
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
configure:24550: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "curl"
| #define PACKAGE_TARNAME "curl"
| #define PACKAGE_VERSION "-"
| #define PACKAGE_STRING "curl -"
| #define PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/"
| #define PACKAGE "curl"
| #define VERSION "7.12.3"
| #define OS "i386-sun-solaris2"
| #define _FILE_OFFSET_BITS 64
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #ifdef __cplusplus
| extern "C" void std::exit (int) throw (); using std::exit;
| #endif
| #define HAVE_GETHOSTBYNAME 1
| #define HAVE_LIBSOCKET 1
| #define HAVE_GETADDRINFO 1
| #define ENABLE_IPV6 1
| #define HAVE_NI_WITHSCOPEID 1
| #define HAVE_O_NONBLOCK 1
| #define HAVE_WRITABLE_ARGV 1
| /* end confdefs.h.  */
|
| /* Override any gcc2 internal prototype to avoid an error.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| /* We use char because int might match the return type of a gcc2
|    builtin and then its argument prototype would still apply.  */
| char CRYPTO_lock ();
| int
| main ()
| {
| CRYPTO_lock ();
|   ;
|   return 0;
| }
configure:24575: result: no