Subject: RPATH and XFree86-libs package
To: None <>
From: Jeremy C. Reed <>
List: tech-pkg
Date: 05/26/2004 15:55:29
On some (maybe all) platforms, the XFree86-libs install has some libraries
that can't find their needed shared objects. For example:

$ ldd /usr/X11R6/lib/ => not found

reed@puget:/usr/pkgsrc/x11$ !ldd
ldd /usr/X11R6/lib/ => not found => not found => not found => not found

I was able to work-around this problem under Linux with by adding to the

#define SharedLibraryLoadFlags -shared -Wl,@RPATH_FLAG@$(USRLIBDIRPATH)

And in the Makefile.common post-extract sed replacement add:
-e "s|@RPATH_FLAG@|${RPATH_FLAG}|g" \

Then it was fine:

reed@puget:/usr/pkgsrc/x11/XFree86-libs$ ldd /usr/X11R6/lib/ => /usr/X11R6/lib/ (0x40018000) => /usr/X11R6/lib/ (0x40071000) => /usr/X11R6/lib/ (0x4007b000) => /usr/X11R6/lib/ (0x40097000) => /usr/X11R6/lib/ (0x400a8000) => /usr/lib/ (0x40192000) => /usr/lib/ (0x402a3000)
        /usr/lib/ => /usr/lib/ (0x80000000)

Looking at xc/config/cf/, I see:

#ifndef LibraryRpathLoadFlags
# if UseRpath
#  if UseElfFormat
#   define LibraryRpathLoadFlags        -rpath $(USRLIBDIRPATH)
#  else
#   define LibraryRpathLoadFlags        -R $(USRLIBDIRPATH)

and then:

#ifndef SharedLibraryLoadFlags
# if UseElfFormat
#  define SharedLibraryLoadFlags        -shared LibraryRpathLoadFlags

But the Linux setup use EXTRA_LOAD_FLAGS as set by ExtraLoadFlags which is
defined with RpathLoadFlags which is -Wl,-rpath,$(USRLIBDIRPATH) when
UseRpath is YES. (If I understand this.)

I tried defining:
#define UseRpath YES
#define RpathLoadFlags -Wl,-rpath,$(USRLIBDIRPATH)

But that didn't work for me. (It was not used.)

Does anyone have any comments on the SharedLibraryLoadFlags above?

Will that be okay for other platforms?

Can anyone test? (I can provide patch if desired.)

 Jeremy C. Reed

 	  	 	 technical support & remote administration