这篇文章详细介绍了使用libevhtp在Windows系统下的编译和安装过程(包括SSL的安装),这篇文章使用的libevhtp版本是1.2.11n,版本不同安装方法可能略有差异。

Linux系统下的安装方法请参看:在Linux下编译安装libevhtp

安装OpenSSL

本文中用到的OpenSSL版本是openssl-OpenSSL_1_0_1u (开始使用的版本是openssl-OpenSSL_1_1_0,但是在源码中没有找到ms\do_ms)。

构建需求(Visual C++)

In addition to the requirements and instructions listed in INSTALL,
this are required as well:

  • You need Perl. We recommend ActiveState Perl, available from https://www.activestate.com/ActivePerl.
    You also need the perl module Text::Template, available on CPAN. Please read NOTES.PERL for more information.
  • You need a C compiler. OpenSSL has been tested to build with these:

    • Visual C++
  • Netwide Assembler, a.k.a. NASM, available from http://www.nasm.us,
    is required if you intend to utilize assembler modules. Note that NASM is the only supported assembler. The Microsoft provided assembler is NOT

supported.

本机的部分环境变量如下:

%SystemRoot%\system32;
%SystemRoot%;
D:\Strawberry\c\bin;
D:\Strawberry\perl\site\bin;
D:\Strawberry\perl\bin;
C:\Program Files (x86)\NASM;

构建OpenSSL

打开Visual Studio Command Prompt (2010) ,依次输入下列命令:

$ cd openssl-OpenSSL_1_0_1u
$ perl Configure VC-WIN32 --prefix="F:\ThirdParty\openssl\openssl" --openssldir="F:\ThirdParty\openssl\ssl"
$ ms\do_ms
$ nmake -f ms\nt.mak 
$ nmake -f ms\nt.mak test
$ nmake -f ms\nt.mak install
  • Configure命令对安装进行配置,其中VC-WIN32是指定构建的平台,可选的参数有(选择其中之一):VC-WIN32 | VC-WIN64A | VC-WIN64I | VC-CE ,如果想要构建debug版本使用debug-VC-WIN32参数即可。--prefix参数指定库文件和头文件(libincludebin)的安装位置,如果不指定将会默认安装到%ProgramFiles(86)%\OpenSSL目录。--openssldir参数指定OpenSSL的安装路径,如果不指定将会默认安装到%CommonProgramFiles(86)%\SSL目录。
  • do_ms是源代码ms目录下的批处理文件,如果想要构建64位的库使用ms\do_win64a命令。
  • nmake用于构建源码,默认构建的静态库,如果想要构建动态库可以指定使用ms\\ntdll.mak

更详细的安装说明请查看OpenSSL源文件目录下的INSTALLNOTES.WINNOTES.PERL文件,但是千万不要盲目相信源目录下的安装方法。

安装libevent

本例中使用的libevent版本是2.0.22-stable ,使用nmake编译。更新版本已经支持使用CMake编译。

编译32位库打开Visual Studio Command Prompt (2010) ,编译64位库打开Visual Studio x64 Win64 Command Prompt (2010) ,依次输入下列命令:

$ cd <libevent source dir>
$ nmake -f makefile.nmake

可以跟根据实际情况修改makefile.nmake文件,已知可以修改的配置如下:

# WATCH OUT!  This makefile is a work in progress.  It is probably missing
# tons of important things.  DO NOT RELY ON IT TO BUILD A GOOD LIBEVENT.

# By default, Makefile.nmake builds without OpenSSL, as before. But if you uncomment the line:
OPENSSL_DIR=F:\ThirdParty\openssl\openssl

!IFDEF OPENSSL_DIR
SSL_CFLAGS=/I$(OPENSSL_DIR)\include /DEVENT__HAVE_OPENSSL
!ELSE
SSL_CFLAGS=
!ENDIF

# Needed for correctness
#CFLAGS=/IWIN32-Code /Iinclude /Icompat /DWIN32 /DHAVE_CONFIG_H /I.
CFLAGS=/IWIN32-Code /Iinclude /Icompat /DWIN32 /DHAVE_CONFIG_H /I. $(SSL_CFLAGS)
# 添加WIN32_WINNT宏定义(根据系统平台更改值,好像已经可以省略)
CFLAGS=$(CFLAGS) /D_WIN32_WINNT=0x0501  
# 消除DEPRECATE警告
CFLAGS=$(CFLAGS) /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE  

# For optimization and warnings
# debug模式/Od(禁用优化)
# CFLAGS=$(CFLAGS) /Od /W3 /wd4996 /nologo
# release模式/Ox(完全优化)
CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo

# XXXX have a debug mode (debug模式添加-D_DEBUG)
# CFLAGS=$(CFLAGS) -D_DEBUG
# debug版本添加调试信息,x86可以使用/ZI
#CFLAGS=$(CFLAGS) /ZI
# debug版本添加调试信息,x64可以使用/Zi
# CFLAGS=$(CFLAGS) /Zi

LIBFLAGS=/nologo
# 64位库添加/MACHINE:X64  
# LIBFLAGS=$(LIBFLAGS) /MACHINE:X64

CORE_OBJS=event.obj buffer.obj bufferevent.obj bufferevent_sock.obj \
    bufferevent_pair.obj listener.obj evmap.obj log.obj evutil.obj \
    strlcpy.obj signal.obj bufferevent_filter.obj evthread.obj \
    bufferevent_ratelim.obj evutil_rand.obj
WIN_OBJS=win32select.obj evthread_win32.obj buffer_iocp.obj \
    event_iocp.obj bufferevent_async.obj
EXTRA_OBJS=event_tagging.obj http.obj evdns.obj evrpc.obj

# 添加输出文件*_openssl.lib *_openssl.obj
!IFDEF OPENSSL_DIR
SSL_OBJS=bufferevent_openssl.obj
SSL_LIBS=libevent_openssl.lib
!ELSE
SSL_OBJS=
SSL_LIBS=
!ENDIF

# 添加pthreads输出文件
THR_OBJS=evthread.obj
THR_LIBS=libevent_pthreads.lib

# 添加$(SSL_OBJS)
ALL_OBJS=$(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS) $(SSL_OBJS) $(THR_OBJS)
# 添加$(SSL_LIBS)
STATIC_LIBS=libevent_core.lib libevent_extras.lib libevent.lib $(SSL_LIBS) $(THR_LIBS)

all: static_libs tests

static_libs: $(STATIC_LIBS)

libevent_core.lib: $(CORE_OBJS) $(WIN_OBJS)
    lib $(LIBFLAGS) $(CORE_OBJS) $(WIN_OBJS) /out:libevent_core.lib 

libevent_extras.lib: $(EXTRA_OBJS)
    lib $(LIBFLAGS) $(EXTRA_OBJS) /out:libevent_extras.lib

libevent.lib: $(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS)
    lib $(LIBFLAGS) $(CORE_OBJS) $(EXTRA_OBJS) $(WIN_OBJS) /out:libevent.lib
    
# how to make "libevent_openssl"
libevent_openssl.lib: $(SSL_OBJS)
    lib $(LIBFLAGS) $(SSL_OBJS) /out:libevent_openssl.lib

# how to make "libevent_pthreads"
libevent_pthreads.lib: $(THR_OBJS)
    lib $(LIBFLAGS) $(THR_OBJS) /out:libevent_pthreads.lib

# 添加clean
clean:
    del $(ALL_OBJS)
    del $(STATIC_LIBS)
    cd test
    $(MAKE) /F Makefile.nmake clean
    cd ..

tests:
    cd test
    $(MAKE) /F Makefile.nmake

如果libevhtp执行cmake时提示LIBEVENT_PTHREADS_LIBRARY(ADVANCED)错误则需要编译输出libevent_pthreads.lib ,否则不需要。

安装libevhtp

安装libevhtp是个很麻烦的过程,遇到了很多问题,经过无数次的失败与重试,终于编译成功了。

打开命令提示符工具Visual Studio Command Promp ,依次输入下列命令:

$ cd <libevhtp source dir>/build
$ cmake -G "MinGW Makefiles" $(params) ..
$ mingw32-make  # 或执行 nmake

可以使用cmake-gui工具替换cmake命令,其中$(params)参数的详细信息如下(Commandline options块中,不需全部输入,仅供参考):

Commandline options:
-DLIBEVENT_INCLUDE_DIR:PATH="F:/ThirdParty/libevent/include" -DCMAKE_C_FLAGS:STRING="" -DCMAKE_LINKER:FILEPATH="D:/Strawberry/c/bin/ld.exe" -DCMAKE_CXX_FLAGS_DEBUG:STRING="-g" -DCMAKE_OBJCOPY:FILEPATH="D:/Strawberry/c/bin/objcopy.exe" -DCMAKE_CXX_STANDARD_LIBRARIES:STRING="-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32" -DEVHTP_DISABLE_EVTHR:BOOL="1" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-O2 -g -DNDEBUG" -DCMAKE_C_STANDARD_LIBRARIES:STRING="-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32" -DCMAKE_RANLIB:FILEPATH="D:/Strawberry/c/bin/ranlib.exe" -DHAS_SYS_ONIG:FILEPATH="HAS_SYS_ONIG-NOTFOUND" -DLIBEVENT_CORE_LIBRARY:FILEPATH="F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_core.lib" -DEVHTP_DISABLE_SSL:BOOL="0" -DLIBEVENT_LIBRARY:FILEPATH="F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent.lib" -DLIBEVENT_EXTRA_LIBRARY:FILEPATH="F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_extras.lib" -DEVHTP_DISABLE_REGEX:BOOL="1" -DCMAKE_STRIP:FILEPATH="D:/Strawberry/c/bin/strip.exe" -DCMAKE_AR:FILEPATH="D:/Strawberry/c/bin/ar.exe" -DCMAKE_INSTALL_PREFIX:PATH="C:/Program Files (x86)/libevhtp" -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O3 -DNDEBUG" -DLIB_WS32:FILEPATH="C:/Windows/System32/ws2_32.dll" -DCMAKE_CXX_FLAGS:STRING="" -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="-O2 -g -DNDEBUG" -DCMAKE_NM:FILEPATH="D:/Strawberry/c/bin/nm.exe" -DCMAKE_RC_COMPILER:FILEPATH="D:/Strawberry/c/bin/windres.exe" -DCMAKE_COLOR_MAKEFILE:BOOL="1" -DLIB_EAY:FILEPATH="F:/ThirdParty/openssl/openssl/lib/libeay32.lib" -DSSL_EAY:FILEPATH="F:/ThirdParty/openssl/openssl/lib/ssleay32.lib" -DCMAKE_C_FLAGS_RELEASE:STRING="-O3 -DNDEBUG" -DLIBEVENT_OPENSSL_LIBRARY:FILEPATH="F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_openssl.lib" -DEVHTP_BUILD_SHARED:BOOL="0" -DCMAKE_C_FLAGS_DEBUG:STRING="-g" -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING="-Os -DNDEBUG" -DCMAKE_OBJDUMP:FILEPATH="D:/Strawberry/c/bin/objdump.exe" -DCMAKE_C_FLAGS_MINSIZEREL:STRING="-Os -DNDEBUG" -DCMAKE_SH:FILEPATH="CMAKE_SH-NOTFOUND" -DCMAKE_C_COMPILER:FILEPATH="D:/Strawberry/c/bin/gcc.exe" -DOPENSSL_INCLUDE_DIR:PATH="F:/ThirdParty/openssl/openssl/include" -DCMAKE_MAKE_PROGRAM:FILEPATH="D:/Qt/Qt5.5.0/Tools/mingw492_32/bin/mingw32-make.exe" -DLIBEVENT_PTHREADS_LIBRARY:FILEPATH="F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_pthreads.lib" -DCMAKE_CXX_COMPILER:FILEPATH="D:/Strawberry/c/bin/g++.exe" 


Cache file:
LIBEVENT_INCLUDE_DIR:PATH=F:/ThirdParty/libevent/include
CMAKE_C_FLAGS:STRING=
CMAKE_LINKER:FILEPATH=D:/Strawberry/c/bin/ld.exe
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
CMAKE_OBJCOPY:FILEPATH=D:/Strawberry/c/bin/objcopy.exe
CMAKE_CXX_STANDARD_LIBRARIES:STRING=-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
EVHTP_DISABLE_EVTHR:BOOL=1
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_C_STANDARD_LIBRARIES:STRING=-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
CMAKE_RANLIB:FILEPATH=D:/Strawberry/c/bin/ranlib.exe
HAS_SYS_ONIG:FILEPATH=HAS_SYS_ONIG-NOTFOUND
LIBEVENT_CORE_LIBRARY:FILEPATH=F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_core.lib
EVHTP_DISABLE_SSL:BOOL=0
LIBEVENT_LIBRARY:FILEPATH=F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent.lib
LIBEVENT_EXTRA_LIBRARY:FILEPATH=F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_extras.lib
EVHTP_DISABLE_REGEX:BOOL=1
CMAKE_STRIP:FILEPATH=D:/Strawberry/c/bin/strip.exe
CMAKE_AR:FILEPATH=D:/Strawberry/c/bin/ar.exe
CMAKE_INSTALL_PREFIX:PATH=C:/Program Files (x86)/libevhtp
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
LIB_WS32:FILEPATH=C:/Windows/System32/ws2_32.dll
CMAKE_CXX_FLAGS:STRING=
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_NM:FILEPATH=D:/Strawberry/c/bin/nm.exe
CMAKE_RC_COMPILER:FILEPATH=D:/Strawberry/c/bin/windres.exe
CMAKE_COLOR_MAKEFILE:BOOL=1
LIB_EAY:FILEPATH=F:/ThirdParty/openssl/openssl/lib/libeay32.lib
SSL_EAY:FILEPATH=F:/ThirdParty/openssl/openssl/lib/ssleay32.lib
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
LIBEVENT_OPENSSL_LIBRARY:FILEPATH=F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_openssl.lib
EVHTP_BUILD_SHARED:BOOL=0
CMAKE_C_FLAGS_DEBUG:STRING=-g
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_OBJDUMP:FILEPATH=D:/Strawberry/c/bin/objdump.exe
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_SH:FILEPATH=CMAKE_SH-NOTFOUND
CMAKE_C_COMPILER:FILEPATH=D:/Strawberry/c/bin/gcc.exe
OPENSSL_INCLUDE_DIR:PATH=F:/ThirdParty/openssl/openssl/include
CMAKE_MAKE_PROGRAM:FILEPATH=D:/Qt/Qt5.5.0/Tools/mingw492_32/bin/mingw32-make.exe
LIBEVENT_PTHREADS_LIBRARY:FILEPATH=F:/ThirdParty/libevent/2.0.22_lib/x86_release/libevent_pthreads.lib
CMAKE_CXX_COMPILER:FILEPATH=D:/Strawberry/c/bin/g++.exe

cmake生成成功后输出的信息如下,供大家参考:

The C compiler identification is GNU 4.9.2
The CXX compiler identification is GNU 4.9.2
Check for working C compiler: D:/Strawberry/c/bin/gcc.exe
Check for working C compiler: D:/Strawberry/c/bin/gcc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: D:/Strawberry/c/bin/g++.exe
Check for working CXX compiler: D:/Strawberry/c/bin/g++.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Warning (dev) at examples/CMakeLists.txt:3 (add_executable):
  Policy CMP0037 is not set: Target names should not be reserved and should
  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  The target name "test" is reserved or not valid for certain CMake features,
  such as generator expressions, and may result in undefined behavior.
This warning is for project developers.  Use -Wno-dev to suppress it.


CMake Warning (dev) at examples/CMakeLists.txt:3 (add_executable):
  Policy CMP0037 is not set: Target names should not be reserved and should
  match a validity pattern.  Run "cmake --help-policy CMP0037" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  The target name "test" is reserved or not valid for certain CMake features,
  such as generator expressions, and may result in undefined behavior.
This warning is for project developers.  Use -Wno-dev to suppress it.


EVHTP_VERSION            :  1.2.11
EVHTP_DISABLE_SSL        :  OFF
EVHTP_DISABLE_EVTHR      :  ON
EVHTP_DISABLE_REGEX      :  ON
EVHTP_BUILD_SHARED       :  OFF
EVHTP_USE_JEMALLOC       :  OFF
EVHTP_USE_TCMALLOC       :  OFF

CMAKE_BUILD_TYPE         : 
CMAKE_INSTALL_PREFIX     : C:/Program Files (x86)/libevhtp
CMAKE_BINARY_DIR         : F:/ThirdParty/libevhtp-1.2.11n/build
CMAKE_CURRENT_BINARY_DIR : F:/ThirdParty/libevhtp-1.2.11n/build
CMAKE_SOURCE_DIR         : F:/ThirdParty/libevhtp-1.2.11n
CMAKE_CURRENT_SOURCE_DIR : F:/ThirdParty/libevhtp-1.2.11n
PROJECT_BINARY_DIR       : F:/ThirdParty/libevhtp-1.2.11n/build
PROJECT_SOURCE_DIR       : F:/ThirdParty/libevhtp-1.2.11n
CMAKE_MODULE_PATH        : F:/ThirdParty/libevhtp-1.2.11n/cmake
CMAKE_SYSTEM_NAME        : Windows
CMAKE_SYSTEM_VERSION     : 6.1.7601
CMAKE_C_COMPILER         : D:/Strawberry/c/bin/gcc.exe
CMAKE_AR                 : D:/Strawberry/c/bin/ar.exe
CMAKE_RANLIB             : D:/Strawberry/c/bin/ranlib.exe
CFLAGS                   : -DEVHTP_HAS_C99 -DNO_STRNDUP -DNO_SYS_UN -DEVHTP_SYS_ARCH=32 -DWIN32  -DPROJECT_VERSION="1.2.11" -Wall -fvisibility=hidden
                              -O3 -DNDEBUG

Configuring done
CMake Warning (dev) at examples/CMakeLists.txt:22 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "test_proxy" of target "examples" does not exist.
This warning is for project developers.  Use -Wno-dev to suppress it.

Generating done

cmake执行时如果出现 CMake Error at <cmake path>/Modules/FindOpenSSL.cmake:293 list GET given empty list错误,下载CMake最新版再重新尝试。

如果使用libevhtp时提示undefined reference to inet_pton 错误,在cmake命令后添加-D_WINVER=0x0600 -D_WIN32_WINNT 0x0600参数。

编译成功后,会在<libevhtp source dir>/build目录生成libevhtp.a文件,如果是动态编译(EVHTP_BUILD_SHARED)还会生成libevhtp.dll.a

使用libevhtp

使用libevhtp创建https服务器非常简单,使用下面几行代码即可创建一个简单的https服务器。

#include "stdafx.h"
#include <stdint.h>
#include <evhtp.h>

void testcb(evhtp_request_t *req, void *a)
{
    const char *str = (const char *)a;

    evbuffer_add_printf(req->buffer_out, "%s", str);
    evhtp_send_reply(req, EVHTP_RES_OK);
}

int _tmain(int argc, _TCHAR* argv[])
{
    WSADATA wsa={0};
    WSAStartup(MAKEWORD(2,2),&wsa);
    evbase_t *evbase    = event_base_new();
    evhtp_t *htp        = evhtp_new(evbase, NULL);
    
    /* ssl support */
    evhtp_ssl_cfg_t ssl_cfg;
    memset(&ssl_cfg, 0, sizeof(evhtp_ssl_cfg_t));
    char ciphers[256] = "RC4+MD5:RC4-SHA:DES-CBC3-SHA:RC4+RSA:HIGH:+MEDIUM:+LOW";    // 密码
    /* ssl support */
    ssl_cfg.pemfile            = "F:/ThirdParty/openssl-OpenSSL_1_0_1u/certs/demo/ca-cert.pem";    // "/etc/wpdconfig/server.crt";
    ssl_cfg.privfile           = "F:/ThirdParty/openssl-OpenSSL_1_0_1u/certs/demo/ca-cert.pem"; // "/etc/wpdconfig/server.key";
    ssl_cfg.cafile             = NULL;        // "/etc/wpdconfig/ca.crt";
    ssl_cfg.capath             = NULL;        // "/etc/wpdconfig/";
    ssl_cfg.ciphers            = NULL;        // ciphers
    ssl_cfg.ssl_opts           = SSL_OP_NO_SSLv2;
    ssl_cfg.ssl_ctx_timeout    = 60 * 60 * 48;
    ssl_cfg.verify_peer        = SSL_VERIFY_NONE;
    ssl_cfg.verify_depth       = 42;
    ssl_cfg.x509_verify_cb     = NULL;
    ssl_cfg.x509_chk_issued_cb = NULL;
    ssl_cfg.scache_type        = evhtp_ssl_scache_type_internal;
    ssl_cfg.scache_size        = 1024;
    ssl_cfg.scache_timeout     = 1024;
    ssl_cfg.scache_init        = NULL;
    ssl_cfg.scache_add         = NULL;
    ssl_cfg.scache_get         = NULL;
    ssl_cfg.scache_del         = NULL;

    if (evhtp_ssl_init(htp, &ssl_cfg) == -1)
    {
        printf("evhtp_ssl_init failed\n");
        return 0;
    }

    evhtp_set_cb(htp, "/simple/", testcb, "simple");
    evhtp_set_cb(htp, "/1/ping", testcb, "one");
    evhtp_set_cb(htp, "/1/ping.json", testcb, "two");
#ifndef EVHTP_DISABLE_EVTHR
    evhtp_use_threads(htp, NULL, 4, NULL);
#endif
    evhtp_bind_socket(htp, "0.0.0.0", 8081, 1024);

    event_base_loop(evbase, 0);

    evhtp_unbind_socket(htp);
    evhtp_free(htp);
    event_base_free(evbase);

    return 0;
}

其中唯一的难点是生成SSL证书,由于CA证书还没申请下来,本例使用了openssl的示例证书,当然你也可以自己生成证书。

相关文章:
Building OpenSSL for Visual Studio
OpenSSL 安装与配置
nmake、cmake、Visual Studio编译libevent

标签: Windows, libevhtp, SSL, libevent, HTTPS, OpenSSL

已有 3 条评论

  1. daniel1991

    领导您好,我是成都这边的一个工程师,最近在做一个https通信方面的项目。我阅读了您博客里的文章“在Windows系统下编译libevhtp”,我觉得写得相当精彩,条理很清晰,我按照您的思路走了一遍,然后命令行也提示生成了文件,但是我没在文件夹里找到libevhtp.lib或者libevhtp.a文件。还有一个问题想请教您一下,Windows下支持libevhtp吗,我现在感到很怀疑。占用了您的时间,不好意思,同时也很感谢您用您的宝贵时间阅读我的问题,期待能获得您的提点,感激不尽

    1. CMake 之后还有一步 nmake

      1. daniel1991

        领导您好,打扰了您的休息时间,我回复了您的邮箱,把cmd截图发给您了~~~

添加新评论