0

When trying to compile the following code based on the openSSL reference code (https://www.openssl.org/docs/man3.0/man3/RSA_generate_key.html)

#include <openssl/rsa.h>
#include <openssl/evp.h>
int main(){
    EVP_PKEY*pkey=EVP_RSA_gen(1024);

}

It throws the following error:

/usr/bin/ld: /tmp/ccLRNWp1.o: in function `main':
rsa2.c:(.text+0x28): undefined reference to `EVP_PKEY_Q_keygen'
collect2: error: ld returned 1 exit status

I'm compiling with the next command.

gcc  -I/usr/include/openssl/ rsa2.c  -lcrypto -lssl 

And my openssl version is

openssl version
OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.0.7 1 Nov 2022)

What I might be missing?

Per Mertesacker
  • 149
  • 2
  • 6

1 Answers1

0

Question solved following undefined reference to `EVP_PKEY_CTX_new_id' first comment. Just be sure that you are linking to a correct directory since the directory name may change from lib to lib64

Per Mertesacker
  • 149
  • 2
  • 6