简体   繁体   中英

OpenSSL fatal error LNK1120: 3 unresolved externals

I've installed OpenSSL to Windows 8, and did the necessary modifications to the OpenSSL library, without installing it as a native library. But I've a specific error message that I couldn't find it on internet.

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 ==========

Hope you guys find something. So here it goes:

#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;
}

I ran that code and it compiled successfully in visual studio 2012, I used OpenSSL-Win32. If OpenSSL-Win64 does not work use OpenSSL-Win32, I also had the same problem. Don't forget to include ssleay32.lib, I hope you know how to configure OpenSSl in visual studio. 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM