[C++] 在windows下编译libevent 2.0

在下载的libevent里面是没有visual studio的项目文件的。编译起来比较麻烦。

下面是我整理的一个vcproj项目文件。需要的同学请另存为libevent-2.0.4-alpha.vcproj,放在“D:/project/libevent-2.0.4-alpha/libevent-2.0.4-alpha”目录下。

目录不一致的话自己修改一下。提供这个项目文件的主要目的有两个:1,列出哪些文件是windows下编译需要的;2,以实际例子来说明项目应该如何设置才能正确编译。

<?xml version="1.0" encoding="gb2312"?> <VisualStudioProject ProjectType="Visual C++" Version="8.00" Name="libevent-2.0.4-alpha" ProjectGUID="{B416800C-EFE8-40E1-AE68-595394166DD6}" RootNamespace="libevent204alpha" Keyword="Win32Proj" > <Platforms> <Platform Name="Win32" /> </Platforms> <ToolFiles> </ToolFiles> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="4" UseOfMFC="0" CharacterSet="1" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""D:/project/libevent-2.0.4-alpha/compat";"D:/project/libevent-2.0.4-alpha/WIN32-Code";"D:/project/libevent-2.0.4-alpha/include"" PreprocessorDefinitions="WIN32;_DEBUG;_LIB" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="true" DebugInformationFormat="4" DisableSpecificWarnings="4018;4227;4267;4244;4311;4996;4133;4312" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLibrarianTool" /> <Tool Name="VCALinkTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="4" CharacterSet="1" WholeProgramOptimization="1" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" PreprocessorDefinitions="WIN32;NDEBUG;_LIB" RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="true" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLibrarianTool" /> <Tool Name="VCALinkTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File RelativePath="../buffer.c" > </File> <File RelativePath="../buffer_iocp.c" > </File> <File RelativePath="../bufferevent.c" > </File> <File RelativePath="../bufferevent_async.c" > </File> <File RelativePath="../bufferevent_filter.c" > </File> <File RelativePath="../bufferevent_pair.c" > </File> <File RelativePath="../bufferevent_ratelim.c" > </File> <File RelativePath="../bufferevent_sock.c" > </File> <File RelativePath="../evdns.c" > </File> <File RelativePath="../event.c" > </File> <File RelativePath="../event_iocp.c" > </File> <File RelativePath="../event_tagging.c" > </File> <File RelativePath="../evmap.c" > </File> <File RelativePath="../evrpc.c" > </File> <File RelativePath="../evthread.c" > </File> <File RelativePath="../evthread_pthread.c" > </File> <File RelativePath="../evthread_win32.c" > </File> <File RelativePath="../evutil.c" > </File> <File RelativePath="../evutil_rand.c" > </File> <File RelativePath="../listener.c" > </File> <File RelativePath="../log.c" > </File> <File RelativePath="../signal.c" > </File> <File RelativePath="../strlcpy.c" > </File> <File RelativePath="../win32select.c" > </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File RelativePath="../bufferevent-internal.h" > </File> <File RelativePath="../changelist-internal.h" > </File> <File RelativePath="../defer-internal.h" > </File> <File RelativePath="../evbuffer-internal.h" > </File> <File RelativePath="../evdns.h" > </File> <File RelativePath="../event-internal.h" > </File> <File RelativePath="../event.h" > </File> <File RelativePath="../evhttp.h" > </File> <File RelativePath="../evmap-internal.h" > </File> <File RelativePath="../evrpc-internal.h" > </File> <File RelativePath="../evrpc.h" > </File> <File RelativePath="../evsignal-internal.h" > </File> <File RelativePath="../evthread-internal.h" > </File> <File RelativePath="../evutil.h" > </File> <File RelativePath="../ht-internal.h" > </File> <File RelativePath="../http-internal.h" > </File> <File RelativePath="../iocp-internal.h" > </File> <File RelativePath="../ipv6-internal.h" > </File> <File RelativePath="../log-internal.h" > </File> <File RelativePath="../minheap-internal.h" > </File> <File RelativePath="../mm-internal.h" > </File> <File RelativePath="../ratelim-internal.h" > </File> <File RelativePath="../strlcpy-internal.h" > </File> <File RelativePath="../util-internal.h" > </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > </Filter> <File RelativePath="./ReadMe.txt" > </File> </Files> <Globals> </Globals> </VisualStudioProject>

我用这个项目文件编译出来的libevent可以正确的运行sample目录下的helloworld例子。

(helloworld例子没有WSAStartup,需要自己加一下才能运行)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值