c++ - 未解析的外部符号“公共:静态浮点 __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 Test C:\Users\user\Source\Repos\RSA Test\ RSA Test\RSA Test.obj,第 1 行
- 错误 LNK2001 无法解析外部符号 __imp_encrypt_or_decrypt RSA Test C:\Users\user\Source\Repos\RSA Test\RSA Test\RSA Test.obj,第 1 行
- 错误 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 prime_2, float public_exponent);
static float encrypt_or_decrypt(float data, float exponent, 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;
}
解决方案
推荐阅读
- regex - 消极展望的替代方案
- javascript - 试图在滚动视频上获得模糊效果
- python - 熊猫将迭代添加列添加到数据框
- soap - SSRS 报告 - XML 查询
- reactjs - 如何在打字稿中的变体“临时”的抽屉组件上设置 zIndex
- python - 如何将数据插入到 Azure SQL 数据库上的表中,并且通过 Airflow DAG 使用 Azure Key Vault 对少数列进行加密
- c - Cygwin 无法链接 libexif 程序
- r - 如何将字符串连接到列表的每个元素?
- flutter - 如何使用 Flutter 的 google_sign_in 插件获取刷新令牌
- javascript - 由于 MIME 类型 (“text/html”) 不匹配 (X-Content-Type-Options: nosniff),来自“http://localhost:3000/js/extra.js”的资源被阻止