致命错误:openssl/aes.h文件或目录不存在

5
我已经在程序所在的文件夹中包含了aes.h文件,但仍然不知道需要做什么其他的事情,请提供建议。提前致谢。
  root@ubuntu:/home/giri/openssl-1.0.1g1/crypto/aes# gcc -Wall aes1.c -lcrypto
  aes1.c:4:25: fatal error: openssl/aes.h: No such file or directory
  compilation terminated.

  here is the code and ls 
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <openssl/aes.h>

  int main(int argc, char **argv)
  {
   int i;
   int keylength;
   printf("Give a key length [only 128 or 192 or 256!]:\n");
   scanf("%d", &keylength);

   /* generate a key with a given length */
   unsigned char aes_key[keylength];
   memset(aes_key, 0, sizeof(aes_key));
   if (!RAND_bytes(aes_key, keylength))
  {
    exit(-1);
   }
   aes_key[keylength-1] = '\0';

   int inputslength;
   printf("Give an input's length:\n");
   scanf("%d", &inputslength);

   /* generate input with a given length */
   unsigned char aes_input[inputslength+1];
   memset(aes_input, '0', sizeof(aes_input));
   aes_input[inputslength] = '\0';


  root@ubuntu:/home/giri/openssl-1.0.1g1/crypto/aes# ls
  aes1.c     aes_core.c  aes.h       aes_misc.c  aes_x86core.c  Makefile.save
  aes_cbc.c  aes_ctr.c   aes_ige.c   aes_ofb.c   asm            README
  aes_cfb.c  aes_ecb.c   aes_locl.h  aes_wrap.c  Makefile       securiti.c

你能给我们展示一下包含 #include 语句的那一行,以及你目录中的 ls 吗? - blackbird
这是编辑过的代码。 - jessica
看起来你的 gcc 命令需要一个 -I 标志来指向 OpenSSL 头文件的位置。 - hymie
2个回答

20

您需要安装OpenSSL开发库。

$ sudo apt-get install libssl-dev

1
我想知道为什么他们没有把这个包叫做libopenssl。 - Antonio

0
对于那些仍然被阻止的人,您可以将此行替换为:'#include "aes.h"'(在此之前,您必须将 'aes.h' 添加到程序所在的文件夹中)
(用 "aes.h" 替换 <openssl/aes.h>)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接