我已将 OpenSSL 安装到 Windows 8,并对 OpenSSL 库进行了必要的修改,但没有将其作为 native 库安装。但是我有一个特定的错误消息,我无法在互联网上找到它。
1>------ Build started: Project: CryptoProject, Configuration: Debug Win32 ------
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol _BN_new referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _BN_bn2dec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _BN_generate_prime referenced in function _main
1>C:\Users\...\...\...\Debug\EXAMPLE.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
希望你们能找到一些东西。所以这里是:
#include <iostream>
#include <string>
#include "openssl/bn.h"
using namespace std;
int main()
{
BIGNUM * q = BN_new();
BIGNUM * two = BN_new();
long int num_bits_q = 160;
long int num_bits_p = 1024;
BN_generate_prime(q, num_bits_q, 0, two, NULL,NULL,NULL);
cout << "q is: " << BN_bn2dec(q) << endl;
return 0;
}
最佳答案
我运行该代码并在 visual studio 2012 中成功编译,我使用的是 OpenSSL-Win32。如果 OpenSSL-Win64 不起作用,请使用 OpenSSL-Win32,我也遇到了同样的问题。不要忘记包含 ssleay32.lib,希望您知道如何在 visual studio 中配置 OpenSSL。
关于c++ - OpenSSL fatal error LNK1120 : 3 unresolved externals,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13915763/