libevent linux安装
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安装的更多相关文章
- Linux上Libevent的安装
1.下载wget -O libevent-2.0.21-stable.tar.gz https://github.com/downloads/libevent/libevent/libevent-2. ...
- Linux安装Memcached服务
环境: CentOS 6.4 libevent-1.4.14b-stable memcached-1.4.21 查看是否安装libevent[root@localhost ~]# rpm -qa |g ...
- memcached在linux安装
服务器端主要是安装memcache服务器端.下载:http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz另外,Memcache用到了lib ...
- linux安装memcacehed
1.wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz 2.wget http://www.monkey.o ...
- 搜狗输入法linux安装 以及 12个依赖包下载链接分享
搜狗输入法linux安装版,先安装各种依赖包,大概12个依赖,可能中途还需要其他依赖,可以效仿解决依赖问题.如图这12个文件要是手动点击下载,那也太笨点了,我们要用shell命令批量下载.命令如下:w ...
- linux安装php
接上篇:linux安装apache 一.安装php 先安装libxml2库 [root@ctxsdhy package]# yum -y install libxml2-devel 最新地址在:htt ...
- linux安装oracle11g
准备oracle安装文件 Oracle11gR2包含两个文件linux_11gR2_database_1of2.zip和linux_11gR2_database_2of2.zip,将这两个文件通过SS ...
- TODO:Linux安装PHP MongoDB驱动
TODO:Linux安装PHP MongoDB驱动 PHP利于学习,使用广泛,主要适用于Web开发领域. MongoDB的主要目标是在键/值存储方式(提供了高性能和高度伸缩性)以及传统的RDBMS系统 ...
- Symantec Backup Exec 2010 Agent For Linux安装
以前写过一篇文章介绍过Symantec Backup Exec 2012 Agent For Linux安装安装,今天介绍一下Symantec Backup Exec 2010 Agent For L ...
随机推荐
- 2016 C++及系统软件技术大会亮点
2016 C++及系统软件技术大会将于201610月28日-29日在上海举办!此次2016 C++及系统软件技术大会秉承"全球专家. 连接智慧"的理念!大会特邀C++之父Bjarn ...
- struts2防止重复提交的标签
struts2 token 使用说明 --------------------------------------------------------------------------------- ...
- Spring MVC集成slf4j-logback
转自: Spring MVC集成slf4j-logback 1. Spring MVC集成slf4j-log4j 关于slf4j和log4j的相关介绍和用法,网上有很多文章可供参考,但是关于logb ...
- jQuery获取元素的兄弟节点的几种方法
$('#id').siblings() //当前元素所有的兄弟节点 $('#id').prev() //当前元素前一个兄弟节点 $('#id').prevaAll() //当前元素之前所有的兄弟节点 ...
- java 邮件发送 apache commons-email
package com.sun.mail;import org.apache.commons.mail.Email;import org.apache.commons.mail.EmailExcept ...
- sql分页带参数,带排序等,动态实现的方法
USE [YQOBS] GO /****** Object: StoredProcedure [dbo].[PageList] Script Date: 11/06/2014 11:39:35 *** ...
- erlang程序优化点的总结(持续更新)
转自:http://wqtn22.iteye.com/blog/1820587 转载请注明出处 注意,这里只是给出一个总结,具体性能需要根据实际环境和需要来确定 霸爷指出,新的erlang虚拟机有很多 ...
- javascript动画效果之缓冲动画(修改版)
在编写多块同时触发运动的时候,发现一个BUG, timer = setInterval(show, 30);本来show是一个自定义函数,当设为timer = setInterval(show(one ...
- Set下面HashSet,TreeSet和LinkedHashSet的区别
Set接口Set不允许包含相同的元素,如果试图把两个相同元素加入同一个集合中,add方法返回false.Set判断两个对象相同不是使用==运算符,而是根据equals方法.也就是说,只要两个对象用eq ...
- C++设计模式-Iterator迭代器模式
ref: http://www.cnblogs.com/onlycxue/archive/2013/12/25/3490738.html