c++ - Visual Studio Intellisense 找到函数,但编译器没有
问题描述
我正在使用 OpenSSL 来尝试让 SHA512 哈希函数工作。当我编写代码时,Visual Studio 的智能感知会找到该函数SHA512
以及其中包含的所有参数,但是当我去构建项目时,我收到错误,“函数 main 中引用了未解析的外部符号 SHA512。 " 这是我到目前为止所拥有的,它基于这里的一个小例子。
标准数据文件
// 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 <stdio.h>
#include <tchar.h>
#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 <afx.h>
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <iostream>
// TODO: reference additional headers your program requires here
#include <openssl/sha.h>
测试.cpp
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
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;
}
我什至检查并确认 SHA512 也在 stdafx.h 文件中包含的 sha.h 文件中。
解决方案
推荐阅读
- python-2.7 - 如何在 sqlite3 中创建多个“:memory:”数据库
- node.js - 使用范围包运行 npx
- android - 如何从后台获取数据并显示通知?
- d3.js - d3.js v5:无法获取要在美国地图上显示的数据点
- java - 如何在java中找到数组中最高值和第二高值的位置
- c# - 计算可能的颜色组合 - Unity3D
- python - TypeError:无法解压不可迭代的 NoneType 对象 Zbar Raspberry pi
- python - 如何在 Keras 中使用经过训练的模型进行预测
- binary - 编写一个程序来添加一个二进制文件
- c# - 优化涉及 Where Newbie C# / LINQ 问题的 LINQ 查询