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

Re: Can't find a library that's right there



I've found several solutions, and have a theory of the problem.  If
anyone could comment on the theory, that would be great.

SOLUTIONS
The best solution seems to be to include
-Wl,-rpath,/usr/lib/R/bin
as an option to gcc.

Setting LD_LIBRARY_PATH also worked, when I remembered to export
it. (duh)

Editing ld.so.conf also worked.

Only the first meets my needs, since I want to redistribute the work
(as part of an R package), and it needs to work without extra
environment tweaking.

THEORY
I'm still puzzled the the -L/usr/lib/R/bin didn't work.  My theory is
that the linker simply sticks in a reference to mspath.so, but does
not attempt to resolve its dependencies.  That only happens at
run-time, at which point -L (but not -runpath) is lost.  Does that
sound right?


RESPONSES TO EARLIER POSTS

I wasn't sure that LD_LIBRARY_PATH affects links.  However the link
command line included -L.  Further, in the examples further down in my
original post I ran the program both with my default LD_LIBRARY_PATH
(empty) and with /usr/lib/R/bin in it (but only set locally).  As the
examples showed, in neither case was the program able to find libR.so,
nor could ldd.

By the way, as shown in the original post, mspath.so also had
-L/usr/lib/R/bin -lR in its link command.

On Sat, Aug 21, 2004 at 12:08:25PM -0400, Kevin B. McCarty wrote:
> > g++ -o test1 mspathCEntry_test.o Manager_test.o TestManager.o
> > PathGenerator_test.o TestRecorder.o SimpleRecorder_test.o
> > TimeStepsGenerator_test.o StateTimeClassifier_test.o Environment_test.o
> > SuccessorGenerator_test.o Model_test.o ConstrainedCoefficients_test.o
> > Path_test.o Data_test.o TimeSteps_test.o TimePoint_test.o basic_test.o
> > ../mspath.so -L/usr/lib/debug -lboost_unit_test_framework \
> >          -L/usr/lib/R/bin -lR
> 
> Since you say later that mspath.so depends upon libR.so, I would put the
> -L/usr/lib/R/bin before ../mspath.so in this command.  If that still
> doesn't help, I'm not sure what causes the problem you describe, but try
> this as a workaround:
That didn't help, though I moved the -lR as well.  I think libraries
usually come last in the link line, so any references are picked up.

> 
> - add /usr/lib/R/bin (on a separate line) to /etc/ld.so.conf
> - run /sbin/ldconfig as root

Yes, that works.  (Well, I get an error about R Home directory not
defined, but that's a separate issue.  Further, that error didn't
happen with -runpath).

> 
> Does that help any?  What does "file /usr/lib/R/bin/libR.so" say?
 
$ file /usr/lib/R/bin/libR.so
/usr/lib/R/bin/libR.so: ELF 32-bit LSB shared object, Intel 80386,
version 1 (SYSV), stripped
also
$ file test1
test1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped

Thanks to everyone for their help.



Reply to: