[Fedora-tools-list] how do you link to a different lib location at run time?

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

 



  (hoping this is the appropriate forum for this.)

  i have a project that involves

  1) creating some shared libs in a temporary location
  2) compiling some executables which will link to those libs
     at run time

however, once the above is done, both the executables and the shared
libs will be installed on a totally separate system, in different
locations.  what i want to do is do the "gcc" build of the executables
against the shared libs in their temp location on the build system:

 $ gcc ... -L/temp-dir -llib1 -llib2    # and so on

but when all of the above is moved to the new system, the run-time
linker should use the new location for searching for the shared libs.

  if i call the old and new library locations "/old" and "/new"
respectively, one option is to compile the programs with:

  $ gcc ... -Wl,-R /new -L/old -llib1 -llib2

so the compile will use the current location for library search, but
will embed the rpath value of "/new" in the executable for the new
system.

  however, if i do it this way, it turns out that gcc *demands* that
that new directory exist on the current (build) system.  it doesn't
have to *contain* anything, it just has to exist, and i'd like to
avoid having to create the directory "/new" on the build system if i
could.

  other options include working with /etc/ld.so.conf on the new
system, of course, or using LD_LIBRARY_PATH (although there are
numerous online essays about why this is a bad idea.)

  what's the standard way to do this?  thanks.

rday


[Index of Archives]     [GCC Help]     [Fedora Development]     [Fedora Announce]     [Fedora Legacy Announce]     [Home]     [Fedora Config]     [PAM]     [Red Hat 9]     [Big List of Linux Books]     [Gimp]     [Yosemite News]

  Powered by Linux