使用 OpenSSL 库"___report_rangecheckfailure"构建错误

Build error with "___report_rangecheckfailure" with OpenSSL libs

本文关键字:构建 错误 rangecheckfailure 使用 OpenSSL report      更新时间:2023-10-16

使用vc++ 2010

使用OpenSSL库编译SHA512哈希…

得到这个构建错误:

1>------ Build started: Project: Second, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>  AssemblyInfo.cpp
1>Second.cpp
1>  Second.cpp(64): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>          C:Program Files (x86)Microsoft Visual Studio 10.0VCincludestdio.h(371) : see declaration of 'sprintf'
1>  Generating Code...
1>  .NETFramework,Version=v4.0.AssemblyAttributes.cpp
1>  Microsoft (R) Incremental Linker Version 10.00.40219.01
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1>  
1>  "/OUT:C:UsersBossdocumentsvisual studio 2010ProjectsSecondDebugSecond.exe" /INCREMENTAL "C:Program FilesOpenSSL-Win32libVCstaticssleay32MD.lib" "C:Program FilesOpenSSL-Win32libVCstaticlibeay32MD.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /ASSEMBLYRESOURCE:DebugSecond.Form1.resources /MANIFEST "/ManifestFile:DebugSecond.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:UsersBossdocumentsvisual studio 2010ProjectsSecondDebugSecond.pdb" /ASSEMBLYDEBUG /SUBSYSTEM:WINDOWS /TLBID:1 "/ENTRY:main" /DYNAMICBASE /FIXED:NO /NXCOMPAT /MACHINE:X86 Debugapp.res 
1>  DebugAssemblyInfo.obj 
1>  DebugSecond.obj 
1>  Debugstdafx.obj 
1>  "Debug.NETFramework,Version=v4.0.AssemblyAttributes.obj" 
1>libeay32MD.lib(obj_dat.obj) : error LNK2019: unresolved external symbol ___report_rangecheckfailure referenced in function _OBJ_create_objects
1>libeay32MD.lib(b_print.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
1>C:UsersBossdocumentsvisual studio 2010ProjectsSecondDebugSecond.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

尝试禁用缓冲区溢出安全检查,相同错误…

任何想法吗?一整天都在用Crypto++,没有用,OpenSSL更容易,只是挂了这个错误…

看起来您正在尝试链接到使用较新版本的编译器构建的OpenSSL库。

函数__report_rangecheckfailure是在最近的Visual Studio版本中引入的(详细信息请参阅http://blogs.microsoft.com/cybertrust/2012/01/26/enhancements-to-gs-in-visual-studio-11/)。

所以链接器正在VS2010库中寻找一个直到后来才存在的函数。

至少一个预构建的Windows OpenSSL库的维护者最近从使用较早版本的Visual Studio切换到其他版本,这可能是引发您的问题的原因。

一种解决方案是使用VS2010构建自己的OpenSSL Windows二进制文件(例如参见http://developer.covenanteyes.com/building-openssl-for-visual-studio/)。