Saturday 6 April 2019

c++ - Visual Studio Intellisense finds function, but compiler doesnt

I am working with OpenSSL to try and get the SHA512 Hash function to work. When I am writing the code, Visual Studio's intellisense finds the function SHA512as well as all of the parameters that are included with it, but when I go to build the project, I get the error, "unresolved external symbol SHA512 referenced in function main." Here is what I have so far, it's based on a small example here.



stdafx.h



// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but

// are changed infrequently
//

#pragma once

#include "targetver.h"

#include
#include
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit

#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS // remove support for MFC controls in dialogs

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif

#include
#include // MFC core and standard components
#include // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT

#include // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include




// TODO: reference additional headers your program requires here
#include


test.cpp



#include "stdafx.h"
#include
#include



int main() {
unsigned char digest[SHA512_DIGEST_LENGTH];
char string[] = "hello world";

SHA512((unsigned char*)&string, strlen(string), (unsigned char*)&digest);

char mdString[SHA512_DIGEST_LENGTH * 2 + 1];

for (int i = 0; i < SHA512_DIGEST_LENGTH; i++)

sprintf(&mdString[i * 2], "%02x", (unsigned int)digest[i]);

printf("SHA512 digest: %s\n", mdString);

return 0;
}


I have even checked and confirmed that SHA512 is in the sha.h file that is included in the stdafx.h file as well.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...