Libevent官网:http://libevent.org/
源代码可自行去官网下载,libevent是一个开源的网络库
编译源码库:
首先的修改一些WIN的宏定义,根据自己的操作系统来修改下面三个文件(在文件开头加上即可)
ibevent-2.0.22-stable\event_iocp.c
libevent-2.0.22-stable\evthread_win32.c
libevent-2.0.22-stable\listener.c
#define _WIN32_WINNT 0x0500”(0x0500表示是Windows 2000或以上版本,0x0501是XP版本,具体的版本号可以自己百度,主要在于理解
#define _WIN32_WINNT 0XXXX0 宏的含义,这里指的是系统版本,编译系统)
然后打开VS的命令行提示工具(VS2010,2012,2015都可以)
cd/d E:\libevent\libevent-2.0.22-stable(进入源码目录)
nmake /f Makefile.nmake(使用makefile编译代码)
最终编译出三个静态Lib库
libevent_core.lib:All core event and buffer functionality. This library contains all the event_base, evbuffer, bufferevent, and utility functions.
libevent_extras.lib:This library defines protocol-specific functionality that you may or may not want for your application, including HTTP, DNS, and RPC.
libevent.lib:This library exists for historical reasons; it contains the contents of both libevent_core and libevent_extra. You shouldn’t use it; it may go away in a future version of Libevent.
项目中使用libevent也就是LIB静态库的使用流程
需要用到源码中.h文件,将下面两个目录下的头文件加到需要使用的项目中
E:\libevent\libevent-2.0.22-stable\include,E:\libevent\libevent-2.0.22-stable\WIN32-Code,2个event2目录下的文件可合并一起
例外导入Lib就可以使用libevent了