vs2019 compile and run the test code libevent

First, download the latest https://libevent.org/ Stable releases libevent-2.1.11-stable.tar.gz

Preparation before compilation

Modify the following five files after decompression

  Event_iocp.c evthread_win32.c listener.c added in a macro definition #define _WIN32_WINNT 0x0500

  Modify minheap-internal.h which has a macro definition UINT32_MAX unsupported into UINT_MAX

  Modify Makefile.nmake find = $ CFLAGS (CFLAGS) / Ox / W3 / wd4996 / nologo / Zi sure to add the last option to facilitate debugging

Start compiling

Open x86 Native Tools Command Prompt for VS 2019 switches to the next directory libevent-2.1.11-stable execution nmake / f Makefile.nmake

It will generate 3 lib files

  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.

Not recommended libevent.lib

After compilation use

Newborn became a WIN32-Code to copy everything under WIN32-Code \ nmake directory in the directory to include in to get started

Add in a test project include the directory containing the link to add dependencies ws2_32.lib; wsock32.lib; libevent_core.lib

Test Results

  

 

Guess you like

Origin www.cnblogs.com/BD1A489/p/11707318.html