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. Bullcow 牡牛和牝牛(bzoj 3398)

    Description     约翰要带N(1≤N≤100000)只牛去参加集会里的展示活动,这些牛可以是牡牛,也可以是牝牛.牛们要站成一排.但是牡牛是好斗的,为了避免牡牛闹出乱子,约翰决定任意两只牡 ...

  2. java 操作redis

    使用Java操作Redis需要jedis-2.1.0.jar,如果需要使用Redis连接池的话,还需commons-pool-1.5.4.jar package com.test; import ja ...

  3. mysql 登录中用户管理

    管理员账号 root 新增普通用户 修改root密码

  4. url中去掉index.php,方便redirect()

    01 配置文件 return Array( 'URL_MODEL' => '2',); 02 index.php入口文件下面加入文件 .htaccess -->使用editplus--&g ...

  5. Kettle jdbc连接hive出现问题

    jdbc连接时报如下错误: Error connecting to database [k] : org.pentaho.di.core.exception.KettleDatabaseExcepti ...

  6. 比较不熟的JavaScript点滴,慢慢前行,附带简单复杂化的php小计算器一份

    interface.php <html> <head> <meta charset="utf-8" /> <title>这是一个简单 ...

  7. iOS页面间传值的六种方式

    一般ios页面间的传值方式分为6种:1.属性传值:2.block:3.delegate:4.UserDefault:5.单例:6.通知. 0&1.block 先说我最常用的block吧,属性传 ...

  8. javascript动画效果之透明度

    在css中的filter对应老版本的ie浏览器,opacity对应的是其他浏览器 <!DOCTYPE html> <html> <head> <meta ch ...

  9. 6.编写一个Java应用程序,该应用程序包括2个类:Print类和主类E。Print 类里有一个方法output()功能是输出100 ~ 999之间的所有水仙花数(各位数字的 立方和等于这个三位数本身,如: 371 = 33 + 73 + 13。)在主类E的main方法中来 测试类Print。

    Print类: package com.bao; public class Print { int g,s,b; void outPut() { for(int i=100;i<1000;i++ ...

  10. __doPostBack初识

    周五在公司看到有看到Request.Params["__EVENTARGUMENT"]的代码不解,不解遂上网查找,发现一篇文章<Understanding the JavaS ...