[Top][All Lists]

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

Re: unable to use $ORIGIN in rpath

From: m c
Subject: Re: unable to use $ORIGIN in rpath
Date: Fri, 17 Aug 2007 19:35:35 +0530

when tried with '$$$$' now the link line does contains $
MAKETARGET='g++   -o ././ -shared   -Wl,-Bsymbolic  -Wl,-rpath,$$ORIGIN:$$ORIGIN/../lib:.:../lib  ./obj/debug/sample.o    -ldl -lpthread -lgcc'
g++   -o ././ -shared    -Wl,-Bsymbolic  -Wl,-rpath,$ORIGIN:$ORIGIN/../lib:.:../lib  ./obj/debug/sample.o    -ldl -lpthread -lgcc
but when i checked the rpath in the binary it shows ':/../lib:.:../lib'. now the shell is rplacing $ORIGIN. to fix this i changed RPATHFLAG to
and now the rpath in the binary is showing $ORIGIN.
Thanks Paul for helping.
On 8/15/07, Paul Smith <address@hidden> wrote:
On Wed, 2007-08-15 at 11:16 +0530, m c wrote:
> tried but it didnt work

> MAKETARGET='g++   -o ././ -shared   -Wl,-Bsymbolic  -Wl,-rpath,$ORIGIN:$ORIGIN/../lib:.:../lib  ./obj/debug/sample.o    -ldl -lpthread -lgcc'

> g++   -o ././ -shared    -Wl,-Bsymbolic  -Wl,-rpath,RIGIN:RIGIN/../lib:.:../lib  ./obj/debug/sample.o    -ldl -lpthread -lgcc

Well, now MAKETARGET is being set properly.

The next problem is that in, that variable is recursive (all
variables taken from the environment are recursive) and so it's expanded
by make before being passed to the shell:

> # allows high level make to set dependencies based on target
>       ${MAKETARGET}

Here when ${MAKETARGET} is expanded, the $ORIGIN value in it will be
interpreted by make as an expansion of the variable $O (which is empty)
followed by the string 'RIGIN', which is exactly what you see.

In order to fix THIS you'll have to add an extra level of escaping to
$ORIGIN, so it survives the second expansion.  Note though!  This means
you cannot use this variable directly in Makefile; it will only work in
the sub-makes:

       RPATHFLAG := $$$$ORIGIN:$$$$ORIGIN/../lib:$(RPATHFLAG)

Now the first expansion will leave RPATHFLAG set to '$$ORIGIN:
$$ORIGIN/../lib:' which will be preserved by the sub-make invocation,
then will be expanded to '$ORIGIN:$ORIGIN/../lib:' when the sub-make
runs the command.

Paul D. Smith <address@hidden>          Find some GNU make tips at:             
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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