Compile libevent under Windows

Environment: win8+vs2008

Version: libevent-2.1.8

Unzip to F:\libevent-2.1.8-stable

Open VS2008 command line

F:

cd libevent-2.1.8-stable

nmake /f Makefile.nmake

1. Report an error

regress_http.c(3611) : error C2059: syntax error : '.'

regress_http.c(3654) : error C2059: syntax error : '.'

Go in and take a look at the 3611 lines of code as follows

struct http_server hs= { .port = 0, .ssl = ssl, };

This syntax does not seem to be supported in the VS2008 compilation environment, so I changed it to

struct http_server hs;// = { .port = 0, .ssl = ssl, };

Then according to the C language specification, add a new variable after the variable is defined

hs.port = 0;

hs.ssl = ssl;

other similarities

Continue to execute nmake /f Makefile.nmake

report an error

NMAKE : fatal error U1073: don't know how to make 'print-winsock-errors.obj'

命令findstr /s /i print-winsock-errors *

See where print-winsock-errors.obj is used

发现test\Makefile.nmake:    print-winsock-errors.obj

Search in the test directory and find that the print-winsock-errors.c file does not exist at all

https://github.com/nmathewson/Libevent/blob/master/test/print-winsock-errors.c

You can download the file from github

Continue to execute nmake /f Makefile.nmake

Finish

libevent-2.1.8-stable directory generated

libevent.lib

libevent_core.lib

libevent_extras.lib

three files

When creating a new project, add these three libraries,

Also add the network library that comes with vs

ws2_32.lib

wsock32.lib

Otherwise, compiling the new project will report an error

The header files are in libevent-2.1.8-stable/include

event2/event-config.h在libevent-2.1.8-stable/WIN32-Code/nmake中

To specify compilation as a 32-bit or 64-bit library, you need to modify Makfile.nmake

LIBFLAGS=/nologo

change to

LIBFLAGS=/nologo /MACHINE:X64

or

LIBFLAGS=/nologo /MACHINE:X86

Default is 32 bit







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521929&siteId=291194637