How to install libevent on Debian/Ubuntu/Centos Linux

The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals or regular timeouts.

Here are the simple steps to download, configure, compile, and install libevent on a Linux machine. I have tested these instructions on Debian/Ubuntu and CentOS Linux distributions but they should work on all Linux machines where compilers and make utility are installed. Please take a look at Configuring Ubuntu Linux After Installation to configure your Debian/Ubuntu Linux box for the required tools.

To download the library, go to http://monkey.org/~provos/libevent/ and find the latest stable version. For the purposes of this tutorial, I will show you how to install 1.4.14b-stable. Also, I am going to install the library in /opt/libevent but you can change the location in the steps below a/c to your requirement.

No more waiting, here are the steps:

$ wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
$ tar xzf libevent-1.4.14b-stable.tar.gz
$ cd libevent-1.4.14b-stable
$ ./configure --prefix=/opt/libevent
# hopefully, you haven't encountered any errors so far
$ make
# make install

You should have libevent installed in /opt/libevent. To make sure:

ls -la /opt/libevent

Now, you can use libevent as a library for other cool software e.g. Gearman.

Please feel free to use the comments form below if you have any questions or need more explanation on anything. Use the icons below to share this tutorial with your friends.

tags cloud

linux centos installation ubuntu libevent debian gearman library

popular searches

Comments (write a comment):

I have tried installing libevent , I have followed all the steps but when i checked der is no libevent directory created inside opt. Posted by: Pritesh Gajjan on Dec 13, 2011

@pritesh:

Did you try installing the same version as mentioned in the tutorial? Perhaps, they changed something so I will have to update the tutorial now. Please let me know.

Thanks. Posted by: shahryar on Dec 13, 2011

Hi i need to use this libevent in the socket communication please guide me for that..now i am using select.So i am facing some problems. Posted by: polepalle v nagendra babu on Mar 05, 2012

The instructions miss make install after "make"

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

ls -la /opt/libevent Posted by: Subfader on Mar 30, 2012

After "make" you need to "make install" but when you do that, make sure you're root!
"sudo make install" is the right way! Posted by: TheDevo on Jun 18, 2012

./configure --prefix=/opt/libevent

After this command i am getting error like

bash: ./configure: Permission denied
I have tried chmod but it didnt work. Posted by: bhargav on Oct 13, 2012

leave a comment