You can use pkg-config
to do this easily.
First, build libevent. In this example we will be installing
libevent to /tmp/libevent - you don't have to create this
directory manually, it will be created automatically during the build
process. You do not need to be root to run make install:
$ ./autogen.sh
$ ./configure --prefix=/tmp/libevent
$ make
$ make install
You should now have /tmp/libevent/lib/pkgconfig/libevent.pc:
$ cat /tmp/libevent/lib/pkgconfig/libevent.pc
#libevent pkg-config source file
prefix=/tmp/libevent
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libevent
Description: libevent is an asynchronous notification event loop library
Version: 2.2.0-alpha-dev
Requires:
Conflicts:
Libs: -L${libdir} -levent
Libs.private:
Cflags: -I${includedir}
Notice that prefix is set to the directory we passed as an argument
to ./configure.
Before building tmux add /tmp/libevent/lib/pkgconfig to
PKG_CONFIG_PATH:
$ export PKG_CONFIG_PATH=/tmp/libevent/lib/pkgconfig:$PKG_CONFIG_PATH
$ pkg-config --cflags --libs libevent
-I/tmp/libevent/include -L/tmp/libevent/lib -levent
And then build tmux normally:
$ ./autogen.sh
$ ./configure
$ make
Notice than in order to actually start tmux with your custom
libevent you have to set LD_LIBRARY_PATH correctly:
$ ldd ./tmux
linux-vdso.so.1 (0x00007ffce3d92000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f2f1d77e000)
libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f2f1d527000)
libevent-2.2.so.1 => not found
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f2f1d30b000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2f1cf42000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2f1cd3d000)
/lib64/ld-linux-x86-64.so.2 (0x000055cdf0697000)
$ ./tmux
./tmux: error while loading shared libraries: libevent-2.2.so.1: cannot open shared object file: No such file or directory
$ LD_LIBRARY_PATH=/tmp/libevent/lib ./tmux -V
tmux master
EDIT:
In order to get away with setting LD_LIBRARY_PATH you can set rpath when building tmux:
$ ./configure LDFLAGS="-Wl,-rpath=/tmp/libevent/lib"
$ make
$ ldd ./tmux
linux-vdso.so.1 (0x00007ffcc6de1000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007fbe121a4000)
libncurses.so.5 => /lib64/libncurses.so.5 (0x00007fbe11f4c000)
libevent-2.2.so.1 => /tmp/libevent/lib/libevent-2.2.so.1 (0x00007fbe11cf7000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fbe11adc000)
libc.so.6 => /lib64/libc.so.6 (0x00007fbe11712000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fbe1150e000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fbe112f1000)
/lib64/ld-linux-x86-64.so.2 (0x000055f057ef4000)
$ ./tmux -V
tmux master
libevent.pcor something like that? – Arkadiusz Drabczyk Jul 31 '18 at 18:25