Openssl aes.h [Linker error] undefined reference to

谁说胖子不能爱 提交于 2019-12-22 09:36:42

问题


I tried to make simple test program with AES decryption using OpenSSL ibaries. The compiler/linker shows me an error. Compiler: Dev-Cpp

  [Linker error] undefined reference to `AES_set_decrypt_key'
  [Linker error] undefined reference to `AES_decrypt'  

code:

#include <stdio.h>
#include <openssl/aes.h>
int main(){
AES_KEY k;
unsigned char key[]="2641cf97291c6ea02b930a4e2a824990";
unsigned char in[]="adc8f4ad114433ffaf4597c9738d257c504db763c29d238aa05bd21e1107809f";
unsigned char out[150];

AES_set_decrypt_key(key, 256, &k);
AES_decrypt(in, out, &k);

printf("%s\n", out);

}

Tnx


回答1:


You should link against the openssl libraries - add this to your command line: -lssl -lcrypto

EDIT: you may have to specify explicitly where are the libraries located using the -L option - add a -L<openssl_library_directory> to the command as well



来源:https://stackoverflow.com/questions/10718418/openssl-aes-h-linker-error-undefined-reference-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!