Reputation: 1534
Consider the two commands below for building a simple executable
$ gcc -g -Wall -Wl,--enable-new-dtags -Wl,-rpath,'$ORIGIN'/sharedLibDir -o prog main.c ./sharedLibDir/libdemo.so
$ gcc -g -Wall -Wl,--enable-new-dtags -Wl,-rpath,./sharedLibDir -o prog main.c ./sharedLibDir/libdemo.so
Clearly, one uses a local directory as the RPATH, the other uses $ORIGIN. I cannot see what the difference is between these two (apart from the value of RPATH and RUNPATH in the binary); both allow the executable to be moved around and, provided it has a parallel directory named sharedLibDir, it runs.
What is the point of $ORIGIN? Does it have some additional functionality that I have missed? Thanks in advance.
Upvotes: 2
Views: 3038
Reputation: 8866
If your use $ORIGIN
, the lookup is relative to the directory that contains the executable. If you specifiy a relative directory, it's relative to the current working directory, which is hardly ever what you want.
Upvotes: 7