Study notes, just record this success with Libevent source code to compile. The environment is Mingw+vs2008+msys.
0. Download Libevent Library
http://libevent.org/Download the stable stable version of the library.
1. Compiling
At first I compiled it with MinGW, but there was always a problem. Later, referring to this blog: http://m.blog.csdn.net/blog/bojie5744/39698599, the run environment of VS is included, and then compiled
Call "C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat"
./configure; make; make install;
If you do not install it, the Libevent header file is in the include, and the generated library is in. Libs, because it uses the VS operating environment. So the Libevent source code compiles the library suffix to lib, not the previous a file. copy libevent.lib;libevent_core.lib;libevent_extra.lib; (finally give me the compiled file, convenient for people without the VS compilation environment to download the use.) For later convenience, you can copy the files in the Include directory into the development environment's include, while the. Libs three files can also be copied into the MinGW Lib folder.
2.libevent Test Code
1 #include <winsock2.h>2 #include <event2/event.h>3 #include <event2/event_struct.h> 4 5 int main (int a RGC, char **argv) 6 {7 event timeout;8 return (0); 9}
The Compile option is
g++ test.cpp-iinclude-l.-levent-lws2_32
Note that the test compiles or does not pass. To change the Libevent.lib file name to Event.lib can be passed, the specific why is not clear. As for why the Lib Library of Ms System and MinGW's a library file is different, under Windows MinGW Advanced version, the two are no different, can be called to use.
3.libevent comes with the source of the HTTP server(Http-server.c in sample)View Code
g++ http-server.c-iinclude-l.-levent-lws2_32
This can be used as a server.
Libevent Compiled library: http://files.cnblogs.com/files/wunaozai/libevent.zip
From:http://www.cnblogs.com/wunaozai/p/4550084.html
Compiling libevent source code (Windows)