如何解决未解析的外部符号“public: static float __cdecl RSA::encrypt_or_decrypt(float,float,float)” (?encrypt_or_decrypt@RSA@@SAMMMM@Z)
我无法让应用使用我制作的 C++ 库。
图书馆在https://github.com/Coder4360/RSA/。
该程序名为 RSA Test,我无法构建它(我使用的是 Visual Studio 2019):
- 错误(活动)E0276 名称后跟“::”必须是类或命名空间名称 RSA Test C:\Users\user\Source\Repos\RSA Test\RSA Test\RSA Test.cpp,第 11 行立>
- 错误 LNK2001 未解析的外部符号“public: static float __cdecl RSA::encrypt_or_decrypt(float,float,float)” (?encrypt_or_decrypt@RSA@@SAMMMM@Z) RSA 测试 C:\Users\user\Source\Repos\ RSA 测试\RSA 测试\RSA 测试.obj,第 1 行
- 错误 LNK2001 未解析的外部符号 __imp_encrypt_or_decrypt RSA Test C:\Users\user\Source\Repos\RSA Test\RSA Test\RSA Test.obj,第 1 行
- Error LNK1120 2 unresolved externals RSA Test C:\Users\user\Source\Repos\RSA Test\x64\Release\RSA Test.exe,第 1 行
问题可能出在这里:
RSAlib.h:
#pragma once
#ifdef RSALIB_EXPORTS
#define MATHLIBRARY_API __declspec(dllexport)
#else
#define RSALIB_API __declspec(dllimport)
#endif
extern "C" RSALIB_API float generate_encryption_number(float prime_1,float prime_2);
extern "C" RSALIB_API float generate_decryption_number(float prime_1,float prime_2,float public_exponent);
extern "C" RSALIB_API float encrypt_or_decrypt(float data,float exponent,float encryption_number);
class RSA
{
public:
static float generate_encryption_number(float prime_1,float prime_2);
static float generate_decryption_number(float prime_1,float public_exponent);
static float encrypt_or_decrypt(float data,float encryption_number);
};
RSA 测试.cpp
// RSA Test.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include "RSAlib.h"
using namespace std;
int main()
{
float encrypted = RSA::encrypt_or_decrypt(20,3,3127);
float decrypted = encrypt_or_decrypt(encrypted,2011,3127);
cout << "Encrypted: " << encrypted << endl;
cout << "Decrypted: " << decrypted << endl;
return 0;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。