0

I am attempting to build a RPM for GNU libiconv

I have no problem compiling the source, but when I install to a temporary location the full temporary path of the shared library gets hard-coded into the iconv executable.

I tried adding --disable-rpath to the configure command as it says "do not hardcode runtime library paths" but this doesn't seem to work.

My build command looks like this:

./configure --prefix=/usr/local --disable-rpath && \
make && \
make DESTDIR=/tmp/path install

running ldd /tmp/path/usr/local/bin/iconv I can see the path to /tmp/path/usr/local/lib/libiconv.so.2 is hard-coded

How can I ensure the executable looks for the libraries in their final destination at /usr/local/lib rather than looking for them where they were built?

Tim
  • 554
  • 2
  • 9
  • 20
  • LDFLAGS='-Wl -rpath ' ./configure blablabla Or use patchelf on binary with correct rpath. – Navern Aug 20 '15 at 14:19
  • Or better still, use an existing RPM as a starting point. – Michael Hampton Aug 20 '15 at 15:03
  • looking into the LDFLAGS approach, it seems it should be `-Wl,-rpath,` with commas, This does end up in the Makefile, but doesn't seem to make any difference in the built executable – Tim Aug 20 '15 at 15:13

1 Answers1

0

After completely failing to avoid rpaths in the executable, I ended up patching it afterwards using the chrpath program.

I had to do this in two steps to set the final path and also avoid rpmbuild failing at the check-rpaths stage.

I ended up with this after make:

make DESTDIR=/tmp/path install
chrpath --replace /usr/local/lib /tmp/path/usr/local/bin/iconv
chrpath --convert /tmp/path/usr/local/bin/iconv

I discovered chrpath while reading Fedora's packaging guidelines. Although I'm on CentOS.

This works for me, despite that it's probably not the best way to do it. My inability to build the executable without hard coded paths is beyond me. It may have something to do with the way the iconv executable is built. It's actually built at the make install stage for some reason to do with requiring it's own libraries are installed.

Tim
  • 554
  • 2
  • 9
  • 20