vs2013 compile libevent static library

Get the source code

Download the libevent source code package from the Libevent official website homepage ( http://libevent.org/ ) or github ( https://github.com/libevent/libevent ).

Here we downloaded the libevent-2.0.20-stable.zip version, and after decompression, we get the libevent-2.0.20-stable folder.

Compile static library

x86

Open the VS2013 development command line tool (select "Developer Commmand prompt" developer command prompt), run the command tool.

Then in the "Visual Studio 2013 Command Prompt" program, enter the cd command to enter the source file directory cd /dx:\xxxxxxxxx\libevent-2.0.20-stable, where x:\xxxxxxxxx is decompressed from libevent-2.0.20-stable path.

Then enter the command nmake /f Makefile.nmake static_libs and press   Enter ,

Wait for 1~2 minutes for the static library to be compiled.

This is compiled in 32-bit release mode.

x64

Modify the configuration in Makefile.nmake in the libevent-2.0.20-stable directory and add a LIBFLAGS option /MACHINE:X64 

Open the VS2013 development command line tool (select the x64 command) and run it.

In the "Visual Studio 2013 x64 Native Tool Command Prompt" program, enter the cd command to enter the source file directory cd /dx:\xxxxxxxxx\libevent-2.0.20-stable ,

Then enter the command nmake /f Makefile.nmake clean and press    Enter (because we have compiled the 32-bit version before, we will clean it up first)

Then enter the command nmake /f Makefile.nmake static_libs and press   Enter

Wait for 1~2 minutes for the x64 static library to be compiled.

 

Extract static library

Create a new folder Third_libs (the folder name can be taken by yourself), and create a new include, lib folder in Third_libs.

The include folder contains:

(1) There is event2 folder and other .h files under x:\xxxxxxxxx\libevent-2.0.20-stable\include, copy them to include.

(2) There is event2 folder and other .h files under x:\xxxxxxxxx\libevent-2.0.20-stable\WIN32-Code\*.

        Copy other .h files to include;

        Copy event-config.h in the event2 file to include\event2

(3) x:\xxxxxxxxx\libevent-2.0.20-stable\*.h copy to include

The lib folder contains:

x:\xxxxxxxxx\libevent-2.0.20-stable\ generated three files: libevent.lib, libevent_core.lib and libevent_extras.lib.

 

The editor has uploaded the compiled x86/x64 libevent static library, and friends who don’t want to compile it by themselves can use it directly. (^U^)ノ~YO

 

Guess you like

Origin blog.csdn.net/lt4959/article/details/105379426