对_imp__CryptProtectData@28的未定义引用
Undefined reference to _imp__CryptProtectData@28
我正在尝试使用windows.h和wincrypt.h库构建一个简单的应用程序,以便加密一些字符串。
当我调用函数CryptProtectData(&input, NULL, NULL, NULL, NULL, 0, &output);
时,我得到错误:
error: undefined reference to `_imp__CryptProtectData@28'
我在网上搜索了很多,但没有很多。我还意识到Chromium浏览器使用与我类似的代码来加密和解密其登录,我并没有做什么不同的事情。
我正在使用QtCreator IDE编译我的代码。
我的一些代码:
std::string plaintext="Some plain text";
DATA_BLOB input;
input.pbData = const_cast<BYTE*>(
reinterpret_cast<const BYTE*>(plaintext.data()));
input.cbData = static_cast<DWORD>(plaintext.length());
DATA_BLOB output;
BOOL result = CryptProtectData(&input, NULL, NULL, NULL, NULL,
0, &output);
编辑:忘了说我已经包括了windows.h和wincrypt.h库,当然。
这是由于您没有提供CryptProtectData
函数所需的库文件而导致的链接器错误。您需要将Crypt32
库传递给链接器。
此信息包含在该函数的MSDN文档中。向下滚动到主题的底部以查看信息。
作为一般规则,为了使用API函数,您需要查看函数文档中的Requirements部分。它列出了以下信息:- 最小支持的Windows版本。
- 需要包含的头文件。
- 需要传递给链接器的库文件。
您是否链接到Crypt32.dll
或Crypt32.lib
?将.lib添加到依赖项中。遇到此类错误时,请参阅文档
相关文章:
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- 使用mysql c++连接器的未定义引用
- 对 Scalar ::Scalar() 的未定义引用
- 对复制 CTOR 和 CTOR 的未定义引用
- 对显式实例化的模板函数的未定义引用
- TensorRT (C++ API) 对"createNvOnnxParser_INTERNAL"的未定义引用
- 2个模板化类的非模板友元函数未定义引用错误
- 编译 libfluid 样本控制器时对"event_base_del_virtual"的未定义引用
- 获取对function_name的未定义引用
- 对 'std::thread::_M_start_thread CMake 的未定义引用进行基准测试
- 对结构方法的未定义引用
- 使用内联函数 c++ 的未定义引用
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 对 DLOPEN 的未定义引用
- QT C++中对全局变量的未定义引用
- 快速数学导致对"__pow_finite"的未定义引用
- 对 boost::system::d etail::system_category_instance 的未定义引用,从
- OpenCV 3.4.3 中对 'cv::String::d eallocate()' 错误的未定义引用