win10+cmake+vs2019编译64位libevent

win10+cmake+vs2019编译64位libevent

概要:

  1. 使用平台:win10_64位
  2. 使用工具:cmake、vs2019
  3. 目的:在windows下编译libevent的库文件
  4. 可以实现任意版本的libevent手动编译

工具依赖

1.libevent下载,下载链接:
https://github.com/libevent/libevent.git

2.openssl下载,下载链接:
https://github.com/openssl/openssl

3.MbedTLS下载,下载链接:
https://github.com/ARMmbed/mbedtls.git

4.perl下载,下载链接:
  perl有两种解决方案:

5.nasm下载:https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/

工具说明:

  编译openssl需要依赖perl、nasm,具体详情可以访问github中的相关介绍,相关链接:https://github.com/openssl/openssl/blob/master/NOTES-Windows.txt

Quick start
 -----------

 1. Install Perl

 2. Install NASM

 3. Make sure both Perl and NASM are on your %PATH%

 4. Use Visual Studio Developer Command Prompt with administrative privileges,
    choosing one of its variants depending on the intended architecture.
    Or run "cmd" and execute "vcvarsall.bat" with one of the options x86,
    x86_amd64, x86_arm, x86_arm64, amd64, amd64_x86, amd64_arm, or amd64_arm64.
    This sets up the environment variables needed for nmake.exe, cl.exe, etc.
    See also
    <https://docs.microsoft.com/cpp/build/building-on-the-command-line>

 5. From the root of the OpenSSL source directory enter
    perl Configure VC-WIN32    if you want 32-bit OpenSSL or
    perl Configure VC-WIN64A   if you want 64-bit OpenSSL or
    perl Configure             to let Configure figure out the platform

 6. nmake

 7. nmake test

 8. nmake install

openssl安装过程中需要注意的事项为:

  1. 检查perl的版本,以及perl是否在环境变量path中,查看perl版本时需注意,显示的版本是否与你预期的相同;例如我在编译时,就出现了perl版本与我预期版本不一致的问题,我的问题导致的原因是我安装mysys2,在mysys中安装过perl,而且系统环境变量中指向该perl的路径在我后来安装的perl的路径之前,这就导致了我使用perl时候出现的版本问题。其次避免使用perl的时候出错,建议使用strawberryperl
  2. 检查nasm是否在系统环境变量中
  3. perl、nasm安装成功后,按照上面的操作教程就可以编译成功openssl,至于你想编译32位、还是64位的就可以自己选择。

openssl最简单的安装方式是:使用python,用python安装openssl就存在头文件与lib文件,不影响使用。不想自己编译openssl的同志,完全可以使用python的安装方式去安装

编译 MbedTLS

编译MbedTLS是必不可少的步骤,下载好MbedTLS源文件后使用cmake_gui生成vs的工程,然后使用vs编译MbedTLS即可。需要注意的事情是,cmake中使用config之后记得更改install的路径,因为在vs中编译的时候默认没有权限在改默认路径中创建文件夹以及复制生成好的lib文件;

编译libevent

1.如上链接下载libevent的源代码
2.使用cmake
3.如果没有找到MbedTLS报错,配置MbedTLS的路径:
在这里插入图片描述
该路径为上面编译MbedTLS后其lib所在文件路径

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值