使用VS2015编译openssl1.0.1p

使用VS2015编译openssl1.0.1p会碰到如下错误

constant_time_test.c
        link /nologo /subsystem:console /opt:ref /debug /out:out32\constant_time_test.exe @C:\Users\TANGMA~1\AppData\Local\Temp\nmAEEB.tmp
constant_time_test.obj : error LNK2019: 无法解析的外部符号 ___iob_func,该符号在函数 _main 中被引用
out32\constant_time_test.exe : fatal error LNK1120: 1 个无法解析的外部命令


查看代码文件e_os.h 318行存在如下定义

#    if _MSC_VER>=1300
#     undef stdin
#     undef stdout
#     undef stderr
FILE *__iob_func();
#     define stdin  (&__iob_func()[0])
#     define stdout (&__iob_func()[1])
#     define stderr (&__iob_func()[2])
#    elif defined(I_CAN_LIVE_WITH_LNK4049)

而__iob_func在VS2015没有了。

实际上VS已经定义了宏stdin,stdio,stderr,直接使用VS定义也是可以的。

VS2015中对stdin,stdio,stderr的定义如下:

_ACRTIMP_ALT FILE* __cdecl __acrt_iob_func(unsigned);

#define stdin (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))


为了保持openssl代码的一致,修改e_os.h 318代码如下:

#    if _MSC_VER>=1900
#     undef stdin
#     undef stdout
#     undef stderr
FILE*  __acrt_iob_func(unsigned);
#     define stdin  (__acrt_iob_func(0))
#     define stdout (__acrt_iob_func(1))
#     define stderr (__acrt_iob_func(2))
#    elif _MSC_VER>=1300 && _MSC_VER<1900

#     undef stdin
#     undef stdout
#     undef stderr

或者直接使用VS对宏的定义

#    if _MSC_VER>=1300 && _MSC_VER<1900
#     undef stdin
#     undef stdout
#     undef stderr


编译通过。




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值