How to create software. / configure && make && make install for a custom library that I also build?

I am building tmux-2.0

from sources on a fairly regular Linux host. The first attempt failed as it turned out the version libevent

installed was older than required, so I started first downloading and building libevent-2.0.22

from sources (current at the time of writing).

The libevent

build succeeded flawlessly and I thought I could then repeat the build tmux

with the following:

PKG_CONFIG_PATH=$PATH_TO_MY_BUILT_LIBEVENT/lib/pkgconfig ./configure ...

      

The above challenge succeeded, as did the subsequent ones make

and make install

.

Starting my new build tmux

, however, is aborted with a missing shared object, unsurprisingly libevent-2.0.so.5

:

tmux: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

      

I thought building against a custom library meant it would also be used at runtime? ldd

on mine tmux

gives me:

linux-vdso.so.1 =>  (0x00007fff8f5ff000)
libutil.so.1 => /lib64/libutil.so.1 (0x0000003cf8800000)
libncurses.so.5 => /lib64/libncurses.so.5 (0x0000003cf7e00000)
libevent-2.0.so.5 => not found
librt.so.1 => /lib64/librt.so.1 (0x0000003ce8600000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x0000003cea200000)
libc.so.6 => /lib64/libc.so.6 (0x0000003ce7600000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003cf7200000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003ce7e00000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003ce8200000)
/lib64/ld-linux-x86-64.so.2 (0x0000003ce7200000)

      

So, libevent-2.0.so.5

not found.

Do I have to resort to setting up, I do not know LIBS

, LDFLAGS

or some other variable or switches on the configure

script above, so I do not know the way to my newly built libevent

embedded in binary code tmux

, courtesy ld

?

I don't have root access - a university Linux workstation - and to be honest, I don't need one, I guess. I also don't want to guess with LD_LIBRARY_PATH

or the like. Suffice it to say that execution LD_LIBRARY_PATH=$PATH_TO_MY_LIBEVENT/lib tmux

works great. But I want it to work "by default" by positioning and using mine libevent

.

I assume this solution applies to almost all software using the "GNU build system". What's the right thing to do here?

+3


source to share


1 answer


You have built the library, but the system does not know where the library is located. Since you don't want to install the library, but leave it where you created it, you can solve it with the -rpath=

linker option - it embeds the search path for the libraries into the executable.

Just rebuild your application by adding it to LDFLAGS, for example LDFLAGS="-rpath=/home/mypath/to/libevent"

(but note that this is a linker variant and it is possible that the makefile uses gcc itself as the linker - gcc doesn't know, you need to write it as LDFLAGS="-Wl,-rpath=/home/mypath/to/libevent"

to force gcc to pass the parameter before the actual linker)



By the way, you can actually change the rpath without even recompiling the application - there's a patchelf tool for that job.

+3


source







All Articles