2014-09-27 56 views
3

我已經將文件aes.h包含在程序存在的文件夾中,但仍然不知道還有什麼需要做這個,任何建議。在此先感謝致命錯誤:openssl/aes.h:沒有這樣的文件或目錄

[email protected]:/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'; 


    [email protected]:/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 
+0

您能向我們展示'#include'語句以及您的目錄中的'ls'行嗎? – blackbird 2014-09-27 18:45:37

+0

這裏是編輯的代碼 – jessica 2014-09-27 18:54:24

+0

看起來你的'gcc'命令需要'-I'標誌來指向openssl頭文件的位置。 – hymie 2015-03-10 20:05:28

回答

8

您需要安裝openssl開發庫。

$ sudo apt-get install libssl-dev 
相關問題