使用OpenSSL库使用“___report_rangecheckfailure”构建错误

时间:2015-09-08 03:39:23

标签: c++ visual-studio-2010 openssl sha

使用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.0\VC\include\stdio.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:\Users\Boss\documents\visual studio 2010\Projects\Second\Debug\Second.exe" /INCREMENTAL "C:\Program Files\OpenSSL-Win32\lib\VC\static\ssleay32MD.lib" "C:\Program Files\OpenSSL-Win32\lib\VC\static\libeay32MD.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:Debug\Second.Form1.resources /MANIFEST "/ManifestFile:Debug\Second.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:\Users\Boss\documents\visual studio 2010\Projects\Second\Debug\Second.pdb" /ASSEMBLYDEBUG /SUBSYSTEM:WINDOWS /TLBID:1 "/ENTRY:main" /DYNAMICBASE /FIXED:NO /NXCOMPAT /MACHINE:X86 Debug\app.res 
1>  Debug\AssemblyInfo.obj 
1>  Debug\Second.obj 
1>  Debug\stdafx.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:\Users\Boss\documents\visual studio 2010\Projects\Second\Debug\Second.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

尝试禁用缓冲区溢出安全检查,同样的错误..

有什么想法?用Crypto ++整天尝试,无济于事,OpenSSL更容易,只是挂了这个错误......

1 个答案:

答案 0 :(得分:1)

看起来您正在尝试链接到使用更高版本的编译器构建的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/)。