使用VS2015编译openssl1.0.1p

来源:互联网 发布:无敌淘宝王全文免费 编辑:程序博客网 时间:2024/06/06 08:28

使用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
原创粉丝点击