我試圖使用OpenSSL ibaries進行AES解密的簡單測試程序。編譯器/鏈接器向我顯示一個錯誤。編譯:開發-CPPOpenssl aes.h [鏈接器錯誤]未定義的參考
[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庫。你在做那個嗎? – NPE
不,怎麼做? – Aleksa