openssl aes.h [链接器错误]未定义的引用 [英] Openssl aes.h [Linker error] undefined reference to

查看:171
本文介绍了openssl aes.h [链接器错误]未定义的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用OpenSSL ibaries使用AES解密制作简单的测试程序.编译器/链接器向我显示一个错误.编译器:Dev-Cpp

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'  

代码:

#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

推荐答案

您应针对openssl库进行链接-将其添加到命令行中:-lssl -lcrypto

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

您可能必须使用-L选项明确指定库的位置-将-L<openssl_library_directory>也添加到命令中

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

这篇关于openssl aes.h [链接器错误]未定义的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆