help-make
[Top][All Lists]
Advanced

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

Re: linking at run time problem


From: Paul Smith
Subject: Re: linking at run time problem
Date: Thu, 03 May 2007 08:41:25 -0400

On Wed, 2007-05-02 at 15:19 -0700, g-h-d wrote:
> Your suggestion was correct: Thank you!
> 
>  g++  -o"testing_hal"  ./main.o -Wl,-rpath,/usr/local/lib -lhal_base 
> 
> from what i read -L takes precedence over LD_LIBRARY_PATH (which i could not
> get to work). how could i go about fixing the problem so i don't need
> -rpath?

First, as has been pointed out this is not a GNU make issue; this is an
issue with your compiler suite.

However, you're confusing link-time with run-time.  The -L argument to
the linker tells it where to find libraries at link time, but has no
impact on runtime at all.

LD_LIBRARY_PATH and -rpath both change the runtime linker search path,
but have no effect on link-time search paths.  -rpath is used at link
time, but affects only runtime, by adding a new search path to the
resulting program that the runtime linker will use.  LD_LIBRARY_PATH is
set by the user before he/she invokes the program, and the runtime
linker looks at that as well as the paths in the program (-rpath) and
the default paths configured on the system.


When you use static libraries, link-time is all that matters of course.

When you use dynamic libraries you have to think about both.

If you don't want to use -rpath at all you have three choices: either
have your users always set LD_LIBRARY_PATH, or else have them install
the shared libraries into the standard directories where the runtime
linker will look (typically /lib and /usr/lib), or finally change the
configuration of the runtime linker to look where you do install them
(by modifying /etc/ld.so.conf--at least this is what it is on Linux)




reply via email to

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