关于openssl:PC端openssl和libevent的编译流程

54次阅读

共计 2501 个字符,预计需要花费 7 分钟才能阅读完成。

PC 端 openssl 和 libevent 的编译流程

筹备工作:

1、Perl

倡议应用 5.30 以上版本,自己在应用时发现 28 的版本如同在配置 openssl 的时候有问题。
下载地址:http://strawberryperl.com/
ps:ActivePerl 和 Strawberry Perl 都能够

2、nasm

下载地址:https://www.nasm.us/pub/nasm/stable/
nasm 须要配置环境变量
装置后关上 vs 编译环境(我编译的是 vs2010)
验证 perl 和 nasm 是否装置胜利

编译 openssl
进入 openssl-1.0.2j 目录
执行:

Perl Configure no-asm VC-WIN32 --prefix=D:\openssl_lib

开始编译

ms\do_nasm(动态库)nmake -f ms\nt.mak
nmake -f ms\nt.mak test
nmake -f ms\nt.mak install

最初生成文件在 openssl_lib 目录下

Libevent 编译
进入 libevent-2.0.22-stable 目录
替换 Makefile.nmake 内容如下:

# WATCH OUT!  This makefile is a work in progress.             -*- makefile -*-
#
# I'm not very knowledgeable about MSVC and nmake beyond their most basic
# aspects.  If anything here looks wrong to you, please let me know.
# If OPENSSL_DIR is not set, builds without OpenSSL support.  If you want
# OpenSSL support, you can set the OPENSSL_DIR variable to where you
# installed OpenSSL.  This can be done in the environment:
#   set OPENSSL_DIR=c:\openssl
# Or on the nmake command line:
#   nmake OPENSSL_DIR=C:\openssl -f Makefile.nmake
# Or by uncommenting the following line here in the makefile...
# OPENSSL_DIR=c:\openssl
!IFDEF OPENSSL_DIR
SSL_CFLAGS=/I$(OPENSSL_DIR)\include /DEVENT__HAVE_OPENSSL
!ELSE
SSL_CFLAGS=
!ENDIF
# Needed for correctness
CFLAGS=/IWIN32-Code /IWIN32-Code/nmake /Iinclude /Icompat /DHAVE_CONFIG_H  /DWIN32 /I. $(SSL_CFLAGS)
# For optimization and warnings
CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /MTd /nologo 
# XXXX have a debug mode
LIBFLAGS=/nologo
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
!IFDEF OPENSSL_DIR
SSL_OBJS=bufferevent_openssl.obj
SSL_LIBS=libevent_openssl.lib
!ELSE
SSL_OBJS=
SSL_LIBS=
!ENDIF
ALL_OBJS=$(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS) $(SSL_OBJS)
STATIC_LIBS=libevent_core.lib libevent_extras.lib libevent.lib $(SSL_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
libevent_openssl.lib: $(SSL_OBJS)
lib $(LIBFLAGS) $(SSL_OBJS) /out:libevent_openssl.lib
clean:
del $(ALL_OBJS)
del $(STATIC_LIBS)
tests:

!IFDEF OPENSSL_DIR
 
!ELSE
 
!ENDIF




最初执行:

nmake /f Makefile.nmake OPENSSL_DIR=D:\openssl_lib

openssl_lib 为下面生成文件门路
最初生成 lib 文件在以后 libevent-2.0.22-stable 目录

正文完
 0