Windows 上静态编译 Libevent 2.0.10 并实现一个简单 HTTP 服务器
[
2011-3-30 08:40 | by 张宴 ]

[文章作者:张宴 本文版本:v1.0 最后修改:2011.03.30 转载请注明原文链接:http://blog.zyan.cc/libevent_windows/]
本文介绍了如何在 Windows 操作系统中,利用微软 Visual Studio 2005 编译生成 Libevent 2.0.10 静态链接库,并利用 Libevent 静态链接库,实现一个简单的 HTTP Web服务器程序:httpd.exe。
假设 Visual Studio 2005 的安装路径为“D:\Program Files\Microsoft Visual Studio 8\”,Libevent 2.0.10 解压后的路径为“D:\libevent-2.0.10-stable”。
一、编译生成 Libevent 2.0.10 静态链接库。
1、修改“D:\libevent-2.0.10-stable\event_iocp.c”、“D:\libevent-2.0.10-stable\evthread_win32.c”、“D:\libevent-2.0.10-stable\listener.c”三个文件,在文件开头分别加上一行:
2、鼠标点击Windows左下角的【开始】-【所有程序】,找到【Microsoft Visual Studio 2005】,执行下图中的脚本:

3、按照下图中的方法编译Libevent 2.0.10:

4、生成的“libevent.lib”、“libevent_core.lib”、“libevent_extras.lib”三个文件就是我们需要的 Libevent 静态链接库。

二、利用 Libevent 静态链接库,实现一个简单的 HTTP Web服务器程序
1、打开 Visual Studio 2005,新建一个项目

本文介绍了如何在 Windows 操作系统中,利用微软 Visual Studio 2005 编译生成 Libevent 2.0.10 静态链接库,并利用 Libevent 静态链接库,实现一个简单的 HTTP Web服务器程序:httpd.exe。
假设 Visual Studio 2005 的安装路径为“D:\Program Files\Microsoft Visual Studio 8\”,Libevent 2.0.10 解压后的路径为“D:\libevent-2.0.10-stable”。
一、编译生成 Libevent 2.0.10 静态链接库。
1、修改“D:\libevent-2.0.10-stable\event_iocp.c”、“D:\libevent-2.0.10-stable\evthread_win32.c”、“D:\libevent-2.0.10-stable\listener.c”三个文件,在文件开头分别加上一行:
#define _WIN32_WINNT 0x0500
2、鼠标点击Windows左下角的【开始】-【所有程序】,找到【Microsoft Visual Studio 2005】,执行下图中的脚本:

3、按照下图中的方法编译Libevent 2.0.10:

4、生成的“libevent.lib”、“libevent_core.lib”、“libevent_extras.lib”三个文件就是我们需要的 Libevent 静态链接库。

二、利用 Libevent 静态链接库,实现一个简单的 HTTP Web服务器程序
1、打开 Visual Studio 2005,新建一个项目
