bug-guix
[Top][All Lists]
Advanced

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

bug#41038: gcc creates binaries that don't find their shared libraries


From: Danny Milosavljevic
Subject: bug#41038: gcc creates binaries that don't find their shared libraries
Date: Mon, 4 May 2020 00:12:03 +0200

Hi Bruno,

On Sun, 03 May 2020 01:55:00 +0200
Bruno Haible <address@hidden> wrote:

> $ make
> ...
> gcc -g -O2 -o hello hello.o -ltextstyle
> $ ./hello
> ./hello: error while loading shared libraries: libtextstyle.so.0: cannot open 
> shared object file: No such file or directory

I remember being tripped up by this when I started using Guix.  It is annoying.

I wonder if it's possible to instruct gcc (or ld, I guess) to automatically
add rpath to where it found the respective library.  That's really what we
expect to happen in Guix.

Ugly workaround:

$ wget https://ftp.gnu.org/gnu/gettext/gettext-0.20.1.tar.gz
$ tar xfz gettext-0.20.1.tar.gz
$ guix install make gcc-toolchain binutils glibc gdb gettext m4 autoconf 
automake
# or better: guix environment --pure --ad-hoc gcc-toolchain make coreutils 
binutils glibc gdb gettext m4 autoconf automake sed grep gawk
(env)$ cd gettext-0.20.1/libtextstyle/examples/color-hello
(env)$ ./autogen.sh
(env)$ export LDFLAGS=-Wl,-rpath=`echo $LIBRARY_PATH | sed -e 's;:; 
-Wl,-rpath=;g'` 
(env)$ ./configure
(env)$ make
exit
$ ./hello
Hello

But unfortunately, Makefiles are not standardized in how to add linker
flags--so it's not easy to find out how to do that in general.

The above does work for gettext.

Attachment: pgpHDzj_AAZWT.pgp
Description: OpenPGP digital signature


reply via email to

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