[Cmake] Linux RPATH info in .so files

Amitha Perera perera at cs.rpi.edu
Mon Oct 14 19:53:06 EDT 2002


> I am making gradually progress..... I have found the CMakeCache.txt file to
> prevent RPATH info being produced. Unfortunately now I can't run the program
> at all. I assumed that removing the embedded RPATH information would give me
> a Windows style DLL which could sit anywhere in the PATH. Even when the .so
> is in the current directory now, it won't load it.
> 
> Could someone please help with this?

As Bill had indicated in a previous email, the presence or absence of
the rpath directories is not going to affect you if you move the
libraries around. Unix systems do the dynamic loading differently from
the Unix systems, and is more secure about where it looks for
libraries.

Read the man page for ldconfig. This is the tool that can be used to
specify the paths that the dynamic linker will search. It should
mention that the environment variable LD_LIBRARY_PATH can override and
modify the system-wide defaults. In particular, if you
   export LD_LIBRARY_PATH=.
(modifed appropriately for your shell), you *may* be able to do what
you want.

You *may* be able to specify the current directory as a search
directory by putting something like "-rpath ." or "-Wl,rpath,." into
the link line (by editing CMAKE_CXX_SHLIB_LINK_FLAGS).

In either case, however, the current directory is that in which the
command is run from, not that in which the executable resides.

Another option for you may be a wrapper shell script that sets
LD_LIBRARY_PATH appropriately then launches your executable. Have
a look at how popular packages like Netscape and Mozilla launch
themselves.

Cheers,
Amitha.



More information about the CMake mailing list