我对这段代码有疑问,从现有的.lib(CryptoLib.lib)编写包装函数:
我的代码.ccp
#include "stdafx.h"
#pragma managed(push, off)
#include "CryptoLib.h"
#pragma comment (lib, "CryptoLib.lib")
#pragma managed(pop)
using namespace System;//This is a C++-CLI project.
__declspec(dllexport) void Encrypt(unsigned char *Data, unsigned char *RandomNr)
{
CryptoLib_Encrypt(Data, RandomNr);
}
密码库
#ifndef _CRYPTOLIB_H_
#define _CRYPTOLIB_H_
#define PUBLIC
//This procedure is written in c++ code
extern void CryptoLib_Encrypt(unsigned char *Data, unsigned char *RandomNr);
#endif /* _CRYPTOLIB_H_ */
我已经链接了 cryptolib.h 和 cryptolib,但我仍然得到“未解析的令牌 Cryptolib_Encrypt”和“未解析的外部符号 Cryptolib_Encrypt”错误。
谁能告诉我为什么?
感谢您的帮助
确切的错误消息:
error LNK2028: unresolved token (0A000006) "void __cdecl CryptoLib_Encrypt(unsigned char *,unsigned char *)" (?CryptoLib_Encrypt@@$$FYAXPAE0@Z) referenced in function "void __cdecl Encrypt(unsigned char *,unsigned char *)" (?Encrypt@@$$FYAXPAE0@Z)
error LNK2019: unresolved external symbol "void __cdecl CryptoLib_Encrypt(unsigned char *,unsigned char *)" (?CryptoLib_Encrypt@@$$FYAXPAE0@Z) referenced in function "void __cdecl Encrypt(unsigned char *,unsigned char *)" (?Encrypt@@$$FYAXPAE0@Z)
error LNK1120: 2 unresolved externals
Dumpbin.exe /exports
命令行只
返回
但是我仍然在 Configuration Properties/"C/C++"/General 中添加了 C/C++ Additional Include 目录,Cryptolib.lib
在 Configuation Properties/Linker/Input 中添加了 Additional Dependencies ( )