0

I need to build a wget incomplete executable using gcc for RHEL4 that will use a specific OpenSSL shared lib. LD_LIBRARY_PATH is unset at build time.

This is quite simple by specifying:

LDFLAGS="-W1,-rpath=/usr/local/ssl/lib -L/my_build_dir/usr/local/ssl/lib"

and all is good.

But this makes the RPATH in the dynamic section of my incomplete executable:

Library rpath: [/usr/local/ssl/lib:/my_build_dir/usr/local/ssl/lib]

Is it possible using the gcc toolchain to set the RPATH to only use what is specified using the -rpath option and to ignore all library paths declared at build time?

I have looked at many SO posts today incl.:

I don't understand -Wl,-rpath -Wl, , and What's the difference between -rpath and -L?

but nothing seems to address the issue of removing build info from the final incomplete executable.

EDIT: Here is the full command line for the final link phase.

gcc  -Wall -std=c99 -m32 -march=athlon -mfpmath=sse -msse2 -O2 -pipe -s \
    -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Wall -m32 -march=athlon \
    -mfpmath=sse -msse2 -O2 -pipe -s -Wl,-rpath,/usr/local/ssl/lib \
    -L/my_build_dir/usr/local/ssl/lib -o wget cmpt.o connect.o convert.o \
    cookies.o ftp.o css_.o css-url.o ftp-basic.o ftp-ls.o hash.o host.o \
    html-parse.o html-url.o http.o init.o log.o main.o netrc.o progress.o \
    ptimer.o recur.o res.o retr.o spider.o url.o warc.o utils.o exits.o
    build_info.o iri.o version.o ftp-opie.o openssl.o http-ntlm.o \
    ../lib/libgnu.a /my_build_dir/usr/local/ssl/lib/libssl.so \
    /my_build_dir/usr/local/ssl/lib/libcrypto.so -Wl,-rpath \
    -Wl,/my_build_dir/usr/local/ssl/lib -ldl -lz  -lidn -luuid -lrt

Thanks to the comments of nos and keltar below I can see where the issue is.

Now to work out why configure finishes up specifying the two openssl libs with their fullpath.

EDIT 2: Just to confirm that that the -rpath and -L option are working correctly.

If I rewrite the above command to remove the hard references to the build location of the openssl libs then RPATH in the incomplete executable is set to just /usr/local/ssl/lib.

Full edited command is:

gcc  -Wall -std=c99 -m32 -march=athlon -mfpmath=sse -msse2 -O2 -pipe -s \
    -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Wall -m32 -march=athlon \
    -mfpmath=sse -msse2 -O2 -pipe -s -Wl,-rpath,/usr/local/ssl/lib \
    -L/my_build_dir/usr/local/ssl/lib -o wget cmpt.o connect.o convert.o \
    cookies.o ftp.o css_.o css-url.o ftp-basic.o ftp-ls.o hash.o host.o \
    html-parse.o html-url.o http.o init.o log.o main.o netrc.o progress.o \
    ptimer.o recur.o res.o retr.o spider.o url.o warc.o utils.o exits.o \
    build_info.o iri.o version.o ftp-opie.o openssl.o http-ntlm.o \
    ../lib/libgnu.a -lssl -lcrypto -ldl -lz  -lidn -luuid -lrt
Community
  • 1
  • 1
Rob Wells
  • 36,220
  • 13
  • 81
  • 146
  • 1
    I can't reproduce this, only /usr/local/ssl/lib gets added to the rpath. Can you copy/paste the full command line that gets run when linking ? – nos Jun 20 '14 at 08:31
  • 1
    If your .so specified directly in linking line, it will be added to rpath. If it is being linked with -llibname, it won't. – keltar Jun 20 '14 at 10:02
  • Thanks @keltar. Full command pasted above. It seems you're right. Now I just have to track down why configure is specifying the openssl libs that way. – Rob Wells Jun 20 '14 at 10:15
  • Full command line added above @nos. – Rob Wells Jun 20 '14 at 10:15
  • 1
    @RobWells The rpath gets set because of the last `-Wl,-rpath \ -Wl,/my_build_dir/usr/local/ssl/lib` , that shouldn't be there. If this is added by e.g. autoconf/automake, It's probably so you can run the binary without installing it. I suspect a `make install` will relink the application before installing it and only contain the relevant -rpath – nos Jun 20 '14 at 13:14

0 Answers0