执行:
tar -zxf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure
make
sudo make install
验证是否安装成功:
whereis libevent
输出:
libevent: /usr/local/lib/libevent.la /usr/local/lib/libevent.a /usr/local/lib/libevent.so
头文件路径:
/usr/local/include/event2/
如果要gdb调试libevent 的源码,就要configure 后加一些选项:
$ ./configure -h
……
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
……
可以看到C编译选项:CFLAGS
CPP 编译选项:CPPFLAGS
./configure CPPFLAGS=-ggdb3 CFLAGS=-ggdb3
加上-ggdb3 的选项,那么生成的makefile里面就会加上这个选项,然后make,sudo make install 就行~