I’ve starto today to explore openSSL api for RSA. That’s the simple code:
#include<stdio.h>
#include<openssl/rsa.h>
#include<openssl/engine.h>
int main() {
RSA *rsa;
rsa = RSA_new_();
RSA_free(rsa);
return 0;
}
and i’m compiling with
gcc -I /usr/local/ssl/include -o etc etc
but gcc return error of undefining reference to RSA_new and RSA_free. I’ve check the rsa.h header, and there’s no reference to this two function.
what’s wrong?
I’ve follow the reference guide on openssl website…
EDIT:
gcc output:
gcc -I /usr/local/ssl/include/ -o rsa rsa.c -L/usr/local/ssl/lib -lcrypto
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In functiondlfcn_globallookup':dlopen’
dso_dlfcn.c:(.text+0x1d): undefined reference to
dso_dlfcn.c:(.text+0x33): undefined reference todlsym'dlclose’
dso_dlfcn.c:(.text+0x3d): undefined reference to
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In functiondlfcn_bind_func':dlsym’
dso_dlfcn.c:(.text+0x3b1): undefined reference to
dso_dlfcn.c:(.text+0x490): undefined reference todlerror'dlfcn_bind_var’:
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function
dso_dlfcn.c:(.text+0x511): undefined reference todlsym'dlerror’
dso_dlfcn.c:(.text+0x5f0): undefined reference to
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In functiondlfcn_load':dlopen’
dso_dlfcn.c:(.text+0x667): undefined reference to
dso_dlfcn.c:(.text+0x6de): undefined reference todlclose'dlerror’
dso_dlfcn.c:(.text+0x715): undefined reference to
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In functiondlfcn_pathbyaddr':dladdr’
dso_dlfcn.c:(.text+0x7b1): undefined reference to
dso_dlfcn.c:(.text+0x819): undefined reference todlerror'dlfcn_unload’:
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function
dso_dlfcn.c:(.text+0x87a): undefined reference to `dlclose’
collect2: ld returned 1 exit status
The propblem is that you are linking with
libssland you are using RSA crypto which is part oflibcrypto, another error : there is no function called :RSA_new_:So correct your code:
And compile like that:
EDIT : for the last error(dl functions):