Bill Moseley waxed lyrical on 1/28/04 8:58 PM:
>
> Does IRIX have LD_RUN_PATH? Be nice to store the path in the executable
> instead of having to set LD_LIBRARY_PATH at runtime.
>
> Another option is using -R and -L together. Not sure if that would work
> on IRIX.
>
As usual, Bill, you ask the right questions.
First, I realized that I failed to understand the distinction between
LD_RUN_PATH and LD_LIBRARY_PATH. So I googled it and found this:
http://mail.gnu.org/archive/html/libtool/2001-03/msg00031.html
That explained why I have been frustrated with needing to set the
LD_LIBRARY_PATH in order for my executables to execute; LD_RUN_PATH, I
had assumed, should take care of that. But LD_RUN_PATH is not used *when
running* the executable (this is one of those great UNIX semantic
things...). Instead, LD_RUN_PATH is used *when compiling* to include the
path in the thing that runs. LD_LIBRARY_PATH, on the other hand, is used
*when running* the executable.
Lesson number one, Peter: don't rely on your intuition when it comes to
understanding environment variables.
Corollary to lesson one: google is your friend.
Second, what I also failed to realize was that in order for LD_RUN_PATH
to actually be *used* by the compiler when compiling, I must specify the
LIBS="-L/path/to/lib" on my configure line.
Lesson number two, Peter: use the ./configure --help option to see all
the options and what they do.
Third, and most important for IRIX, had I read more *carefully* the
little ld message when compiling other apps on IRIX, I would have
realized that LD_RUN_PATH is ignored on IRIX. Here's the little ld
message from the IRIX ld output, for those (like me) who usually fail to
notice it as it whizzes by when running 'make':
=================================
Libraries have been installed in:
/path/to/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARYN32_PATH' environment variable
during execution
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
=================================
So lesson number three: don't rely on google for everything. Read the
man pages for my particular operating system.
It wasn't enough for me to learn how to use LD_RUN_PATH (though that
will be helpful for Solaris and others). I needed to know NOT to rely on
it on IRIX.
Armed with these lessons, I recompiled libxml2 and swish-e for IRIX with
the following. NOTE that I use the LD_RUN_PATH variable but I have to
mention it explicitly at the ./configure line.
NOTE too that I do not set the LD_RUN_PATH to include the zlib path. I
tried that, but despite the --use-zlib=/path/to/zlib/irix, make seemed
to use a local version instead from /usr/lib32 (because it was prior in
the path?) and it caused fatal conflicts for making swish-e. Even
without setting /path/zlib in LD_RUN_PATH, I still get warnings during
compile, but they are not fatal, and seem to be fine with swish-e. The
warnings look like:
ld32: WARNING 85: definition of compress in
/path/to/zlib/irix/lib/libz.a(compress.o) preempts that definition in
/usr/lib32/libz.so
I'm sure there are some more options for the IRIX configure that would
compensate for these warnings, but at this point, my laziness prevailed.
It worked, and that was good enough. This happened before when I
compiled the IRIX version and I ignored it then too (at my peril, I'm sure).
libxml2
==========
setenv LD_RUN_PATH /path/to/gcc/lib
configure LDFLAGS="-Wl,-rpath -Wl,$LD_RUN_PATH -L$LD_RUN_PATH" \
--prefix=/path/to/libxml2/irix
make
make install
swish-e
=========
setenv LD_RUN_PATH /path/to/gcc/lib:/path/to/libxml2/irix
configure LDFLAGS="-Wl,-rpath -Wl,$LD_RUN_PATH -L$LD_RUN_PATH" \
--prefix=/path/to/swish-e/2.4.1/irix \
--with-zlib=/path/to/zlib/irix \
--with-libxml2=/path/to/libxml2/irix \
--disable-shared
make
make test
SWISHE:API perl module
=======================
I believe that at this point, the LD_RUN_PATH variable *is* used by the
Perl make process. Does anyone know if the Perl linker is different?? In
any case, doing this:
setenv LD_RUN_PATH /path/to/swishe/lib:/path/to/zlib/lib
and this:
configure LIBS="-L/path/to/swishe/lib -L/path/to/zlib/lib"
appear to achieve the same thing, since this:
setenv LD_RUN_PATH /path/to/swishe/lib:/path/to/zlib/lib
perl Makefile.PL PREFIX=/path/to/swish-e/2.4.1/irix \
CCFLAGS=-I/path/to/swish-e/2.4.1/irix/include \
LIBS="-lswish-e -lz"
seems to work the same as this:
perl Makefile.PL PREFIX=/path/to/swish-e/2.4.1/irix \
CCFLAGS=-I/path/to/swish-e/2.4.1/irix/include \
LIBS="-L/path/to/swish-e/2.4.1/irix/lib -L/path/to/zlib/lib \
-lswish-e -lz"
But I may have missed something here. In any case, again, it works, and
make test passes.
pek
--
Peter Karman - Software Publications Engineer - Cray Inc
phone: 651-605-9009 - mailto:karman@cray.com
Received on Thu Jan 29 05:47:41 2004