未解析的外部符号“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 (将#修改为@)