0

This webpage tells me that we can use $ORIGIN to bake the dir of executable as searching dir into executable. This runpath command can be written as:

-Wl,--enable-new-dtags,-rpath,"\$ORIGIN"

But the shared library I am trying to load is not exactly in the same dir as the executable. It is in a subdir, say LIB, of where the executable is. That webpage does not tell me how to do that. I tried many ways to concatenate LIB but of no avail, like "\$ORIGIN/LIB", "\$ORIGIN"/LIB, \$ORIGIN/LIB or "\$ORIGIN/LIB/". I didn't find any clue from google search either. Can you please tell me the right syntax of $ORIGIN to specify a dir relative to it in runpath flag? Thank you.

PS: I'm working on ubuntu 16.04 with GNU make 4.1 and GNU ld 2.26.1.

user5280911
  • 723
  • 1
  • 8
  • 21

1 Answers1

0

Mike Kinghan is right, "\$ORIGIN/LIB" is nothing wrong. But it is the case only if we actually pass it to the linker. However, I am not using Linux command line. I am using NetBeans. When I type "\$ORIGIN/LIB" literally in Linker->Additional Options, some pre-processing is conducted (by NetBeans or something else) so that it is "\RIGIN/LIB" that is passed to the linker. Fortunately, I finally figured out how to by-pass this pre-processing:

-Wl,--enable-new-dtags,-rpath,"\$$ORIGIN/LIB"

That is, the key is double dollar sign!

user5280911
  • 723
  • 1
  • 8
  • 21