libevent linux 编译,libevent 编译debug版本

最近要把linux下面的代码移植到windows下面,因为用到了libevent,需要编译一下。

windows 7下编译:

编译环境: windows 7 + VS2010

(1)解压libevent到libevent-2.0.21-stable

(2)打开Microsoft visual studio 2010命令行工具

(3)修改以下三个文件,添加宏定义:

在以下3个文件开头#define _WIN32_WINNT 0x0403修改为“#define _WIN32_WINNT 0x0500”

libevent-2.0.21-stable\event_iocp.c

libevent-2.0.21-stable\evthread_win32.c

libevent-2.0.21-stable\listener.c

(4)使用VS命令提示工具编译:

修改Makefile.nmake文件

把/Ox 修改为 /Od /MDd /Zi

如果是64位,添加一个LIBFLAGS选项 /MACHINE:X64

nmake /f Makefile.nmake

(5)编译结果:

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.

copy WIN32-Code\event2\event-config.h 到  include\event2\event-config.h

项目属性设置:

VC++目录:

包含目录,添加:F:\Projects\LibeventTest\LibeventTest\Include;

库目录,添加:F:\Projects\LibeventTest\LibeventTest\Lib;

C/C++:

代码生成-->运行库:多线程调试 (/MTd)(Debug下),多线程 (/MT)(Release下)

连接器:

输入:ws2_32.lib;wsock32.lib;libevent.lib;libevent_core.lib;libevent_extras.lib;

ws2_32.lib;wsock32.lib;是用来编译Windows网络相关的程序库。

代码中加入

初始化

#ifdef WIN32

WSADATA wsa_data;

WSAStartup(0x0201, &wsa_data);

#endif

清理环境

#ifdef WIN32

::WSACleanup();

#endif

阅读(5876) | 评论(0) | 转发(0) |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值