wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
wget http://downloads.sourceforge.net/levent/libevent-2.0.22-stable.tar.gz
tar –xzvf libevent-1.4.13-stable.tar.gz
tar -xzvf libevent-2.0.22-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/home/mydir/libevent
不指定prefix,则可执行文件默认放在/usr /local/bin,
库文件默认放在/usr/local/lib,
配置文件默认放在/usr/local/etc。
其它的资源文件放在/usr /local/share。
你要卸载这个程序,要么在原来的make目录下用一次make uninstall(前提是make文件指定过uninstall),要么去上述目录里面把相关的文件一个个手工删掉。
指定prefix,直接删掉一个文件夹就够了。
make && make install

src:main.cpp

/*
* XXX This sample code was once meant to show how to use the basic Libevent
* interfaces, but it never worked on non-Unix platforms, and some of the
* interfaces have changed since it was first written. It should probably
* be removed or replaced with something better.
*
* Compile with:
* cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent
*/

#include <sys/types.h>

#include <event2/event-config.h>

#include <sys/stat.h>
#ifndef WIN32
#include <sys/queue.h>
#include <unistd.h>
#endif
#include <time.h>
#ifdef _EVENT_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <event2/event.h>
#include <event2/event_struct.h>
#include <event2/util.h>

#ifdef WIN32
#include <winsock2.h>
#endif

struct timeval lasttime;

int event_is_persistent;

static void
timeout_cb(evutil_socket_t fd, short event, void *arg)
{
struct timeval newtime, difference;
struct event *timeout = (struct event *)arg;
double elapsed;

evutil_gettimeofday(&newtime, NULL);
evutil_timersub(&newtime, &lasttime, &difference);
elapsed = difference.tv_sec +
(difference.tv_usec / 1.0e6);

printf("timeout_cb called at %d: %.3f seconds elapsed.\n",
(int)newtime.tv_sec, elapsed);
lasttime = newtime;

if (! event_is_persistent) {
struct timeval tv;
evutil_timerclear(&tv);
tv.tv_sec = 2;
event_add(timeout, &tv);
}
}

int
main(int argc, char **argv)
{
struct event timeout;
struct timeval tv;
struct event_base *base;
int flags;

#ifdef WIN32
WORD wVersionRequested;
WSADATA wsaData;

wVersionRequested = MAKEWORD(2, 2);

(void)WSAStartup(wVersionRequested, &wsaData);
#endif

if (argc == 2 && !strcmp(argv[1], "-p")) {
event_is_persistent = 1;
flags = EV_PERSIST;
} else {
event_is_persistent = 0;
flags = 0;
}

/* Initalize the event library */
base = event_base_new();

/* Initalize one event */
event_assign(&timeout, base, -1, flags, timeout_cb, (void*) &timeout);

evutil_timerclear(&tv);
tv.tv_sec = 2;
event_add(&timeout, &tv);

evutil_gettimeofday(&lasttime, NULL);

event_base_dispatch(base);

return (0);
}

g++ main.cpp -L./libevent/lib -levent -I./libevent/include/
export LD_LIBRARY_PATH=/home/shengkaishan/work/libevent/lib/:$LD_LIBRARY_PATH

libevent linux安装的更多相关文章

  1. Linux上Libevent的安装

    1.下载wget -O libevent-2.0.21-stable.tar.gz https://github.com/downloads/libevent/libevent/libevent-2. ...

  2. Linux安装Memcached服务

    环境: CentOS 6.4 libevent-1.4.14b-stable memcached-1.4.21 查看是否安装libevent[root@localhost ~]# rpm -qa |g ...

  3. memcached在linux安装

    服务器端主要是安装memcache服务器端.下载:http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz另外,Memcache用到了lib ...

  4. linux安装memcacehed

        1.wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz     2.wget http://www.monkey.o ...

  5. 搜狗输入法linux安装 以及 12个依赖包下载链接分享

    搜狗输入法linux安装版,先安装各种依赖包,大概12个依赖,可能中途还需要其他依赖,可以效仿解决依赖问题.如图这12个文件要是手动点击下载,那也太笨点了,我们要用shell命令批量下载.命令如下:w ...

  6. linux安装php

    接上篇:linux安装apache 一.安装php 先安装libxml2库 [root@ctxsdhy package]# yum -y install libxml2-devel 最新地址在:htt ...

  7. linux安装oracle11g

    准备oracle安装文件 Oracle11gR2包含两个文件linux_11gR2_database_1of2.zip和linux_11gR2_database_2of2.zip,将这两个文件通过SS ...

  8. TODO:Linux安装PHP MongoDB驱动

    TODO:Linux安装PHP MongoDB驱动 PHP利于学习,使用广泛,主要适用于Web开发领域. MongoDB的主要目标是在键/值存储方式(提供了高性能和高度伸缩性)以及传统的RDBMS系统 ...

  9. Symantec Backup Exec 2010 Agent For Linux安装

    以前写过一篇文章介绍过Symantec Backup Exec 2012 Agent For Linux安装安装,今天介绍一下Symantec Backup Exec 2010 Agent For L ...

随机推荐

  1. 重载 vs 重写

    http://www.cnblogs.com/lonelyDog/archive/2011/11/16/2251011.html

  2. 第一百零二节,JavaScript函数

    JavaScript函数 学习要点: 1.函数声明 2.return返回值 3.arguments对象 函数是定义一次但却可以调用或执行任意多次的一段JS代码.函数有时会有参数,即函数被调用时指定了值 ...

  3. C#的GridView控件复习

    一,在新建一个空网站 二,在这网站新建一个default.aspx页面 三,添加一个GridView控件 四,新建一个数据库,这个数据库包含你要显示的表数据,这个表须包含主键(表的主键影响增删改的功能 ...

  4. Ctrl+Alt+T恢复启动Ubuntu默认终端

    对于Ubuntu14.04,如果安装了terminator,那么快捷键Ctrl+Alt+T将不会启动自带的terminal,而是启动安装的terminator,如果想恢复回来,可以执行以下命令: su ...

  5. EasyuiAPI:布局

    一.Panel(面板) 1.通过标签创建: <div id="p" class="easyui-panel" title="My Panel&q ...

  6. ERP流程图

  7. Chapter 16_1 Class

    一个类就是一个创建对象的模具.对于一些基于原型的语言,对象是没有“类型”的,而是每个对象都有一个原型(prototype). 原型也是一种常规的对象.当其他对象(类的实例)遇到一个未知操作时,原型会先 ...

  8. 深度探索C++对象模型之C++对象模型笔记

    0.菜鸟觉得,在看这本书的时候最好切换角色,把自己的思维转换成编译器开发者,去考虑问题,这样会容易理解些.(当然这样很难,就想着自己要解决什么样的问题好了) 1.在C++中,类的数据成员有两种:静态和 ...

  9. 【Machine Learning in Action --4】朴素贝叶斯分类

    1.概述 朴素贝叶斯分类是贝叶斯分类器的一种,贝叶斯分类算法是统计学的一种分类方法,利用概率统计知识进行分类,其分类原理就是利用贝叶斯公式根据某对象的先验 概率计算出其后验概率(即该对象属于某一类的概 ...

  10. 对方网络ping不通

    后台接口往往部署在其他服务器上如果ping不同 很大可能是因为对方开防火墙的原因 解决方法:控制面板-windows防火墙-打开或关闭windows防火墙