openssl vs2015编译

工具:

1. 编译环境win10+vs2015专业版

2. ActivePerl工具,官网下载链接:http://www.activestate.com/activeperl/downloads

3. openssl源码,下载链接:https://www.openssl.org/source/选择2016-May-03 13:57:13 openssl-1.0.1t.tar.gz这个版本,之所以没有选择1.1.0,发觉两个版本差异较大,ms文件夹下缺少很多文件,没办法按照此方法编译。

 

步骤:

1. 安装ActivePerl, 并添加环境变量(可以默认勾选,或者手动添加,如path=d:\perl\bin)。

2. 解压openssl。

3. 点击 windows 开始->所有应用->vs2015->开发者命令提示(Developer Command Prompt for 2015)。

4. CD到解压后的openssl的根目录。

5. 执行命令:perl Configure debug-VC-WIN32(或者VC-WIN64A,取决于编译库类型,可以用–prefix=路径指定生成路径).
6. ms\do_ms.bat(创建makefile文件,64位需要使用ms\do_win64a.bat)

7. 执行nmake -f ms\ntdll.mak(编译动态库)。

8. 执行nmake -f ms\ntdll.mak test查看库是否有问题。

9. 执行nmake -f ms\ntdll.mak install 。

 

TIPs:

编译动态库: 
nmake -f ms\ntdll.mak 
编译静态库: 
nmake -f ms\nt.mak 
测试动态库: 
nmake -f ms\ntdll.mak test 
测试静态库: 
nmake -f ms\nt.mak test 
安装动态库: 
nmake -f ms\ntdll.mak install 
安装静态库: 
nmake -f ms\nt.mak install 
清除上次动态库的编译,以便重新编译: 
nmake -f ms\ntdll.mak clean 
清除上次静态库的编译,以便重新编译: 
nmake -f ms\nt.mak clean

 

  • [编译类型]可以选择以下:
参数含义
debug-VC-WIN32编译32位debug版本
VC-WIN32编译32位release版本
debug-VC-WIN64A编译64位debug版本
VC-WIN64A编译64位release版本
  • [输出目录]理论任何地方都可以。自己确定好就行

    • 3)配置模式:

      1. 【编译32位openssl】 
        命令如下:

        ms\do_ms.bat
        • 1

        感谢CSDN网友:WeiXin_zjmgly指出,如果之前编译使用了no-asm参数,则需要修改命令为:

        ms\do_nasm
        • 1

        否则会在编译引用了该openssl库的工程中出现”error LNK2001error LNK2019 无法解析的外部符号”这个错误。(该解决方法由 WeiXin_zjmgly 提供)

      2. 【编译64位openssl】 
        命令如下: 
        ms\do_win64a.bat
        • 1

      执行这一步之后,在ms目录下会生成nt.mak和ntdll.mak两个编译配置文件 
      nt.mak 用于生成静态lib库 
      ntdll.mak 用于生成动态dll库

    4、编译【编译静态库、动态库有区别】

    • 【编译openssl静态链接库】 
      命令如下:
    nmake -f ms\nt.mak
    nmake -f ms\nt.mak test
    nmake -f ms\nt.mak install
    • 【编译openssl动态链接库】 
      命令如下:
    nmake -f ms\ntdll.mak
    nmake -f ms\ntdll.mak test
    nmake -f ms\ntdll.mak install
    • 执行test命令可以测试编译好的库,测试成功了就可以运行install命令,运行完之后才会在输出目录中找到输出的编译好的库和加入工程时必要的include文件。 
      需要注意的地方:

    1)设置编译类型的时候千万别忘记no-asm参数,关闭汇编模式,否则会出现类似如下错误:

    Assembling: tmp32\sha1-586.asm
    tmp32\sha1-586.asm(1427) : error A2070: invalid instruction operands
    tmp32\sha1-586.asm(1571) : error A2070: invalid instruction operands
    NMAKE : fatal error U1077: 'ml' : return code '0x1'
    Stop.

    2)设置VC编译环境的时候,注意有32位和64位的区别,网络上大多数是因为没有注意这个导致编译失败。

    最后附上编译所需的所有命令(一个例子):

    openssl目录:c:\openssl-1.0.2j\ 
    以编译64位release版本的dll为例子:

    cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
    vcvars32.bat
    perl Configure VC-WIN64A no-asm --prefix="c:\openssl-1.0.2j\build-vc14-debug-win64-dll"
    ms\do_win64a.bat
    nmake -f ms\ntdll.mak
    nmake -f ms\ntdll.mak test
    nmake -f ms\ntdll.mak install
    nmake -f ms\ntdll.mak clean
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这两天制作的openssl 的VC工程for openssl-1.0.0e,除DGST和ocsp不能单独生成文件(编译时报错找不到符号,不用理会)外,基本上可生成所有其他的文件。具体列表如下: 2011-09-27 10:48 36,955 4758cca.dll 2011-09-27 10:48 668 4758cca.exp 2011-09-27 10:48 83,888 4758cca.ilk 2011-09-27 10:48 2,108 4758cca.lib 2011-09-27 10:48 132,096 4758cca.pdb 2011-09-27 10:48 32,855 aep.dll 2011-09-27 10:48 652 aep.exp 2011-09-27 10:48 81,216 aep.ilk 2011-09-27 10:48 2,056 aep.lib 2011-09-27 10:48 132,096 aep.pdb 2011-09-27 10:48 57,437 asn1parse.exe 2011-09-27 10:48 293,756 asn1parse.ilk 2011-09-27 10:48 238,592 asn1parse.pdb 2011-09-27 10:48 32,858 atalla.dll 2011-09-27 10:48 665 atalla.exp 2011-09-27 10:48 79,116 atalla.ilk 2011-09-27 10:48 2,094 atalla.lib 2011-09-27 10:48 123,904 atalla.pdb 2011-09-27 10:48 32,858 bftest.exe 2011-09-27 10:48 57,028 bftest.ilk 2011-09-27 10:48 123,904 bftest.pdb 2011-09-27 10:48 49,242 bntest.exe 2011-09-27 10:48 132,236 bntest.ilk 2011-09-27 10:48 164,864 bntest.pdb 2011-09-27 10:48 98,390 ca.exe 2011-09-27 10:48 437,108 ca.ilk 2011-09-27 10:48 312,320 ca.pdb 2011-09-27 10:50 45,144 capi.dll 2011-09-27 10:50 657 capi.exp 2011-09-27 10:50 164,212 capi.ilk 2011-09-27 10:50 2,068 capi.lib 2011-09-27 10:50 164,864 capi.pdb 2011-09-27 10:50 28,764 casttest.exe 2011-09-27 10:50 46,260 casttest.ilk 2011-09-27 10:50 115,712 casttest.pdb 2011-09-27 10:50 36,952 chil.dll 2011-09-27 10:50 657 chil.exp 2011-09-27 10:50 110,116 chil.ilk 2011-09-27 10:50 2,068 chil.lib 2011-09-27 10:50 140,288 chil.pdb 2011-09-27 10:50 57,435 ciphers.exe 2011-09-27 10:50 294,204 ciphers.ilk 2011-09-27 10:50 230,400 ciphers.pdb 2011-09-27 10:51 61,527 crl.exe 2011-09-27 10:51 303,084 crl.ilk 2011-09-27 10:51 238,592 crl.pdb 2011-09-27 10:51 57,437 crl2pkcs7.exe 2011-09-27 10:51 289,828 crl2pkcs7.ilk 2011-09-27 10:51 230,400 crl2pkcs7.pdb 2011-09-27 10:51 36,954 cswift.dll 2011-09-27 10:51 665 cswift.exp 2011-09-27 10:51 88,068 cswift.ilk 2011-09-27 10:51 2,094 cswift.lib 2011-09-27 10:51 132,096 cswift.pdb 2011-09-27 10:51 41,051 destest.exe 2011-09-27 10:51 73,468 destest.ilk 2011-09-27 10:51 123,904 destest.pdb 2011-09-27 11:17 25,600 dgst.pdb 2011-09-27 11:00 57,430 dh.exe 2011-09-27 11:00 295,624 dh.ilk 2011-09-27 11:00 238,592 dh.pdb 2011-09-27 14:42 61,531 dhparam.exe 2011-09-27 14:42 311,364 dhparam.ilk 2011-09-27 14:42 205,824 dhparam.pdb 2011-09-27 11:00 28,762 dhtest.exe 2011-09-27 11:00 73,740 dhtest.ilk 2011-09-27 11:00 123,904 dhtest.pdb 2011-09-27 11:00 57,431 dsa.exe 2011-09-27 11:00 295,496 dsa.ilk 2011-09-27 11:00 238,592 dsa.pdb 2011-09-27 11:00 61,532 dsaparam.exe 2011-09-27 11:00 312,244 dsaparam.ilk 2011-09-27 11:00 246,784 dsaparam.pdb 2011-09-27 11:00 28,763 dsatest.exe 2011-09-27 11:00 67,660 dsatest.ilk 2011-09-27 11:00 123,904 dsatest.pdb 2011-09-27 11:00 32,860 ecdhtest.exe 2011-09-27 11:00 87,668 ecdhtest.ilk 2011-09-27 11:00 132,096 ecdhtest.pdb 2011-09-27 11:00 32,861 ecdsatest.exe 2011-09-27 11:00 100,972 ecdsatest.ilk 2011-09-27 11:00 140,288 ecdsatest.pdb 2011-09-27 11:01 114,778 ectest.exe 2011-09-27 11:01 140,400 ectest.ilk 2011-09-27 11:01 156,672 ectest.pdb 2011-09-27 11:01 61,527 enc.exe 2011-09-27 11:01 320,504 enc.ilk 2011-09-27 11:01 246,784 enc.pdb 2011-09-27 11:01 61,530 engine.exe 2011-09-27 11:01 304,268 engine.ilk 2011-09-27 11:01 238,592 engine.pdb 2011-09-27 11:01 28,766 enginetest.exe 2011-09-27 11:01 78,116 enginetest.ilk 2011-09-27 11:01 123,904 enginetest.pdb 2011-09-27 11:01 57,434 errstr.exe 2011-09-27 11:01 285,692 errstr.ilk 2011-09-27 11:01 230,400 errstr.pdb 2011-09-27 11:01 32,860 evp_test.exe 2011-09-27 11:01 95,560 evp_test.ilk 2011-09-27 11:01 140,288 evp_test.pdb 2011-09-27 11:01 28,763 exptest.exe 2011-09-27 11:01 66,476 exptest.ilk 2011-09-27 11:01 123,904 exptest.pdb 2011-09-27 11:01 57,433 gendh.exe 2011-09-27 11:01 291,808 gendh.ilk 2011-09-27 11:01 238,592 gendh.pdb 2011-09-27 11:01 57,434 gendsa.exe 2011-09-27 11:01 304,916 gendsa.ilk 2011-09-27 11:01 238,592 gendsa.pdb 2011-09-27 11:01 57,434 genrsa.exe 2011-09-27 11:01 306,056 genrsa.ilk 2011-09-27 11:01 246,784 genrsa.pdb 2011-09-27 11:03 28,759 gmp.dll 2011-09-27 11:03 652 gmp.exp 2011-09-27 11:03 27,120 gmp.ilk 2011-09-27 11:03 2,056 gmp.lib 2011-09-27 11:03 99,328 gmp.pdb 2011-09-27 11:03 90,200 gost.dll 2011-09-27 11:03 657 gost.exp 2011-09-27 11:03 287,660 gost.ilk 2011-09-27 11:03 2,068 gost.lib 2011-09-27 11:03 304,128 gost.pdb 2011-09-27 11:04 28,764 hmactest.exe 2011-09-27 11:04 43,464 hmactest.ilk 2011-09-27 11:04 115,712 hmactest.pdb 2011-09-27 11:04 28,764 ideatest.exe 2011-09-27 11:04 49,520 ideatest.ilk 2011-09-27 11:04 115,712 ideatest.pdb 2011-09-27 10:31 1,966,172 libeay32.dll 2011-09-27 10:30 528,619 libeay32.exp 2011-09-27 10:31 1,028,852 libeay32.ilk 2011-09-27 10:30 777,138 libeay32.lib 2011-09-27 10:31 3,802,112 libeay32.pdb 2011-09-27 11:05 28,763 md2test.exe 2011-09-27 11:05 46,176 md2test.ilk 2011-09-27 11:05 115,712 md2test.pdb 2011-09-27 11:05 28,763 Md4test.exe 2011-09-27 11:05 46,176 Md4test.ilk 2011-09-27 11:05 115,712 Md4test.pdb 2011-09-27 11:05 28,763 md5test.exe 2011-09-27 11:05 46,176 md5test.ilk 2011-09-27 11:05 115,712 md5test.pdb 2011-09-27 11:05 28,764 mdc2test.exe 2011-09-27 11:05 46,976 mdc2test.ilk 2011-09-27 11:05 115,712 mdc2test.pdb 2011-09-27 11:05 57,432 nseq.exe 2011-09-27 11:05 271,876 nseq.ilk 2011-09-27 11:05 222,208 nseq.pdb 2011-09-27 11:05 28,761 nuron.dll 2011-09-27 11:05 660 nuron.exp 2011-09-27 11:05 70,028 nuron.ilk 2011-09-27 11:05 2,082 nuron.lib 2011-09-27 11:05 115,712 nuron.pdb 2011-09-27 11:16 25,600 ocsp.pdb 2011-09-27 11:06 528,475 openssl.exe 2011-09-27 11:06 1,795,040 openssl.ilk 2011-09-27 11:06 1,246,208 openssl.pdb 2011-09-27 11:06 32,859 padlock.dll 2011-09-27 11:06 668 padlock.exp 2011-09-27 11:06 55,348 padlock.ilk 2011-09-27 11:06 2,108 padlock.lib 2011-09-27 11:06 115,712 padlock.pdb 2011-09-27 11:20 61,530 passwd.exe 2011-09-27 11:20 295,176 passwd.ilk 2011-09-27 11:20 238,592 passwd.pdb 2011-09-27 11:08 73,818 pkcs12.exe 2011-09-27 11:08 359,452 pkcs12.ilk 2011-09-27 11:08 271,360 pkcs12.pdb 2011-09-27 11:09 57,433 pkcs7.exe 2011-09-27 11:09 289,812 pkcs7.ilk 2011-09-27 11:09 230,400 pkcs7.pdb 2011-09-27 11:09 61,529 pkcs8.exe 2011-09-27 11:09 300,504 pkcs8.ilk 2011-09-27 11:09 246,784 pkcs8.pdb 2011-09-27 11:10 61,528 rand.exe 2011-09-27 11:10 292,972 rand.ilk 2011-09-27 11:10 238,592 rand.pdb 2011-09-27 11:10 28,764 randtest.exe 2011-09-27 11:10 40,288 randtest.ilk 2011-09-27 11:10 115,712 randtest.pdb 2011-09-27 11:10 28,763 rc2test.exe 2011-09-27 11:10 41,996 rc2test.ilk 2011-09-27 11:10 115,712 rc2test.pdb 2011-09-27 11:10 28,763 rc4test.exe 2011-09-27 11:10 49,336 rc4test.ilk 2011-09-27 11:10 115,712 rc4test.pdb 2011-09-27 11:10 28,763 rc5test.exe 2011-09-27 11:10 44,644 rc5test.ilk 2011-09-27 11:10 115,712 rc5test.pdb 2011-09-27 11:11 77,911 req.exe 2011-09-27 11:11 383,556 req.ilk 2011-09-27 11:11 287,744 req.pdb 2011-09-27 11:11 28,763 rmdtest.exe 2011-09-27 11:11 46,536 rmdtest.ilk 2011-09-27 11:11 115,712 rmdtest.pdb 2011-09-27 11:11 57,431 rsa.exe 2011-09-27 11:11 302,520 rsa.ilk 2011-09-27 11:11 238,592 rsa.pdb 2011-09-27 11:11 28,763 rsatest.exe 2011-09-27 11:11 61,252 rsatest.ilk 2011-09-27 11:11 123,904 rsatest.pdb 2011-09-27 11:12 57,434 Rsautl.exe 2011-09-27 11:12 291,084 Rsautl.ilk 2011-09-27 11:12 238,592 Rsautl.pdb 2011-09-27 11:12 57,435 sess_id.exe 2011-09-27 11:12 293,596 sess_id.ilk 2011-09-27 11:12 238,592 sess_id.pdb 2011-09-27 11:12 28,764 sha1test.exe 2011-09-27 11:12 50,176 sha1test.ilk 2011-09-27 11:12 115,712 sha1test.pdb 2011-09-27 11:12 28,763 sha256t.exe 2011-09-27 11:12 50,956 sha256t.ilk 2011-09-27 11:12 115,712 sha256t.pdb 2011-09-27 11:13 28,763 sha512t.exe 2011-09-27 11:13 50,924 sha512t.ilk 2011-09-27 11:13 115,712 sha512t.pdb 2011-09-27 11:13 28,763 shatest.exe 2011-09-27 11:13 50,980 shatest.ilk 2011-09-27 11:13 115,712 shatest.pdb 2011-09-27 11:13 69,721 smime.exe 2011-09-27 11:13 332,916 smime.ilk 2011-09-27 11:13 263,168 smime.pdb 2011-09-27 11:13 102,489 speed.exe 2011-09-27 11:13 405,052 speed.ilk 2011-09-27 11:13 287,744 speed.pdb 2011-09-27 11:14 57,433 spkac.exe 2011-09-27 11:14 302,948 spkac.ilk 2011-09-27 11:14 246,784 spkac.pdb 2011-09-27 10:35 450,652 SSLeay32.dll 2011-09-27 10:35 38,352 SSLeay32.exp 2011-09-27 10:35 445,032 SSLeay32.ilk 2011-09-27 10:35 56,742 SSLeay32.lib 2011-09-27 10:35 656,384 SSLeay32.pdb 2011-09-27 11:14 57,435 ssltest.exe 2011-09-27 11:14 200,740 ssltest.ilk 2011-09-27 11:14 189,440 ssltest.pdb 2011-09-27 11:14 36,956 sureware.dll 2011-09-27 11:14 673 sureware.exp 2011-09-27 11:14 106,624 sureware.ilk 2011-09-27 11:14 2,120 sureware.lib 2011-09-27 11:14 140,288 sureware.pdb 2011-09-27 11:12 94,300 s_client.exe 2011-09-27 11:12 470,172 s_client.ilk 2011-09-27 11:12 336,896 s_client.pdb 2011-09-27 11:12 102,492 s_server.exe 2011-09-27 11:12 492,008 s_server.ilk 2011-09-27 11:12 353,280 s_server.pdb 2011-09-27 11:12 73,818 s_time.exe 2011-09-27 11:12 361,548 s_time.ilk 2011-09-27 11:12 279,552 s_time.pdb 2011-09-27 11:14 36,953 ubsec.dll 2011-09-27 11:14 660 ubsec.exp 2011-09-27 11:14 81,900 ubsec.ilk 2011-09-27 11:14 2,082 ubsec.lib 2011-09-27 11:14 132,096 ubsec.pdb 2011-09-27 11:14 57,434 verify.exe 2011-09-27 11:14 299,372 verify.ilk 2011-09-27 11:14 238,592 verify.pdb 2011-09-27 11:15 57,435 version.exe 2011-09-27 11:15 285,588 version.ilk 2011-09-27 11:15 230,400 version.pdb 2011-09-27 11:15 28,763 wp_test.exe 2011-09-27 11:15 48,836 wp_test.ilk 2011-09-27 11:15 115,712 wp_test.pdb 2011-09-27 11:15 82,008 x509.exe 2011-09-27 11:15 392,568 x509.ilk 2011-09-27 11:15 287,744 x509.pdb

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值