这是我在Windows 10上使用OpenSSL的Codeblocks中使用的代码。但是有一些错误。
#include <openssl/rsa.h>
int main()
{
RSA *r;
int bits=512,ret;
unsigned long e=RSA_3;
BIGNUM *bne;
r=RSA_generate_key(bits,e,NULL,NULL);
RSA_print_fp(stdout,r,11);
RSA_free(r);
bne=BN_new();
ret=BN_set_word(bne,e);
r=RSA_new();
ret=RSA_generate_key_ex(r,bits,bne,NULL);
if(ret!=1)
{
printf("RSA_generate_key_ex err!\n");
return -1;
}
RSA_free(r);
return 0;
}
链接错误:
\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `GetDeviceCaps@8'|
\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `GetDeviceCaps@8'|
\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `CreateCompatibleBitmap@12'|
\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `GetObjectA@12'|
\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `GetDIBits@28'|
\libcrypto.a(rand_win.o):rand_win.c|| undefined reference to `DeleteObject@4'|
怎么了?