70

I want to install tmux on a machine where I don't have root access. I already compiled libevent and installed it in $HOME/.bin-libevent and now I want to compile tmux, but configure always ends with configure: error: "libevent not found", even though I tried to point to the libevent directory in the Makefile.am by modifying LDFLAGS and CPPFLAGS, but nothing seems to work.

How can I tell the system to look in my home dir for the libevent?

volker
  • 703

9 Answers9

68

Try:

DIR="$HOME/.bin-libevent"
./configure CFLAGS="-I$DIR/include" LDFLAGS="-L$DIR/lib"

(I'm sure there must be a better way to configure library paths with autoconf. Usually there is a --with-libevent=dir option. But here, it seems there is no such option.)

  • 4
    This is the approach that made make finally work. I tried setting other environment variables and setting prefix and exec-prefix, but once I included these flags stuff actually got built. – wizonesolutions Jan 10 '13 at 16:34
  • How would I go about specifying multiple directories for the flags? I tried ./configure CFLAGS="-I$DIR/include:/usr/otherdir" LDFLAGS="-L$DIR/lib:/usr/otherdir" but no success – lucaswxp Aug 22 '15 at 19:12
  • 1
    @lucaswxp CFLAGS="-Idir1 -Idir2 -Idir3" LDFLAGS="-Ldira -Ldirb -Ldirb" – Kusalananda Jul 29 '16 at 08:28
  • I used this answer and the libevent not found error went away, but now I get the same with ncurses: curses not found.

    My libevent as well as ncurses installations are both in $HOME/.local/

    – axolotl Jul 27 '18 at 17:28
  • For libevent, use LIBEVENT_CFLAGS and LIBEVENT_LIBS instead of CFLASG and LDFLAGS. For ncurse, use LIBTINFO_CFLAGS and LIBTINFO_LIBS @Aalok – Jongsu Liam Kim Feb 25 '19 at 11:52
  • This worked for me, but how does this work versus putting $HOME in the flag directly? – ansonl Aug 05 '19 at 00:28
10

I was having a similar problem and discovered that after running sudo yum install libevent-devel I was able to successfully make and install tmux.

EDIT: If you are installing this on a Red Hat machine, you will also need to visit the channels selection for your server on the Red Hat Network and add the RHEL Server Optional channel. This will give you access to the -devel packages for libevent (the base and supplementary channels do not provide it).

Snap Shot
  • 219
7

I had the same issue on RHEL 5.4 and actually found libevent is installed but there is no libevent.so symlink, only the real version of the library:

/usr/lib64/libevent-1.1a.so.1
/usr/lib64/libevent-1.1a.so.1.0.2

So, ln -s /usr/lib64/libevent-1.1a.so.1 /usr/lib64/libevent.so works pretty well for me without the need to install or alter anything. No idea why RedHat's libevent rpm didn't create the symlink. Maybe a bug to report?

But now, it's complaining for this: error: event.h: No such file or directory.

Kevin
  • 40,767
cepal
  • 71
  • I got the same exact error: error: event.h: No such file or directory. – gkb0986 Aug 07 '13 at 18:00
  • 1
    I'm on RHEL 6, and I just downloaded and compiled libevent, installing it to a user folder. Then I used @Stéphane Gimenez's trick above to get it compiling. To get it running, I aliases with the LD_PRELOAD trick given by @rozcietrzewiacz: tmux='LD_PRELOAD=/opt-local/lib/libevent-2.0.so.5 /opt-local/bin/tmux'. Works like a charm! – csl Dec 04 '14 at 15:00
  • 1
    If you find yourself messing around with symlinks or manually copying things around in system directories, then there is a better way of doing it. – Kusalananda Jul 29 '16 at 08:30
3

Before the configuration and compilation of tmux (or any program) you need to tell it where it can find the libraries it needs. If you have installed some library in a non-standard location, you can use the environmental variable LD_LIBRARY_PRELOAD to tell, where some libraries are located.

I your case:

$ export LD_LIBRARY_PRELOAD=$HOME/.bin-libevent/lib

And then go on with the configuration/compilation.

Later on, the binary will also need to know where your additional libraries can be found, so you'll need to place the export statement in your .bashrc (if bash is your login shell).

1

There's a gist at https://gist.github.com/ryin/3106801:

#!/bin/bash

# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.

# exit on error
set -e

TMUX_VERSION=1.8

# create our directories
mkdir -p $HOME/local $HOME/tmux_tmp
cd $HOME/tmux_tmp

# download source files for tmux, libevent, and ncurses
wget -O tmux-${TMUX_VERSION}.tar.gz http://sourceforge.net/projects/tmux/files/tmux/tmux-${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz/download
wget https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz

# extract files, configure, and compile

############
# libevent #
############
tar xvzf libevent-2.0.19-stable.tar.gz
cd libevent-2.0.19-stable
./configure --prefix=$HOME/local --disable-shared
make
make install
cd ..

############
# ncurses  #
############
tar xvzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$HOME/local
make
make install
cd ..

############
# tmux     #
############
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}
./configure CFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-L$HOME/local/lib -L$HOME/local/include/ncurses -L$HOME/local/include"
CPPFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-static -L$HOME/local/include -L$HOME/local/include/ncurses -L$HOME/local/lib" make
cp tmux $HOME/local/bin
cd ..

# cleanup
rm -rf $HOME/tmux_tmp

echo "$HOME/local/bin/tmux is now available. You can optionally add $HOME/local/bin to your PATH."
serv-inc
  • 650
  • 1
    I also had curses installed to a custom location (I'm not an admin on the target system), and didn't realize it installs itself to the ncurses subdirectory of whatever include/ library path you specify. Odd design choice. This fixed it for me. – wbadart Mar 15 '19 at 18:59
1

The accepted answer is good, but as of at least tmux 2.8 there is support for specifying libevent location using environment variables.

First install libevent in desired location. I used cmake because I had a problem with autoconf

cmake -DCMAKE_INSTALL_PREFIX=$HOME/usr ..
make install

Then build and install tmux:

export LIBEVENT_CFLAGS=-I${HOME}/usr/include 
export LIBEVENT_LIBS="-L${HOME}/usr/lib -levent" 
./configure --prefix=$HOME/usr
make install

The environment variable LIBEVENT_CFLAGS overrides pkg-config include settings for libevent, and LIBEVENT_LIBS overrides the linker flag settings.

0

I have the same problem and it seems the most upvoted answer didn't work for me. I am using Fedora 22 Workstation. Here is what I did to fix this: 1. Install libevent-devel package. 2. Install ncurses-devel package

$ dnf install libevent-devel`
$ dnf install ncurses-devel

First one will solve no event.h problem and second will solve cannot find curses problem. BTW, the softlink method above also works for me during ./configure.

TPS
  • 2,481
0

This installed latest version of tmux and libevent, worked for me on AWS Linux 2:

# Install tmux 3.3

install deps

sudo yum install -y gcc kernel-devel make ncurses-devel

DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL

curl -LOk https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz tar -xf libevent-2.1.11-stable.tar.gz cd libevent-2.1.11-stable ./configure --prefix=/usr/local make sudo make install

DOWNLOAD SOURCES FOR TMUX AND MAKE AND INSTALL

curl -LOk https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz tar -xf tmux-3.3a.tar.gz cd tmux-3.3a LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" ./configure --prefix=/usr/local make sudo make install

pkill tmux

close your terminal window (flushes cached tmux executable)

open new shell and check tmux version

tmux -V

Similar to this gist: https://gist.github.com/muralisc/dbb998a8555acc577ce2cf7aae8cd9fa

social
  • 299
-3

On CentOS 6, compile and install libevent in /opt/libevent directory with the command:

# ./configure --prefix=/opt/libevent
# make
# make install

Then, install my aplication (in this case was PgBouncer)

# ./configure --prefix=/opt/ *--with-libevent=/opt/libevent/*

You can change the directories wherever you want.

X Tian
  • 10,463
Cepxio
  • 1