与OpenSSL的链接错误 [英] Link error with OpenSSL
本文介绍了与OpenSSL的链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经安装了OpenSSL。我只是想使用OpenSSL运行一个程序。
I have installed OpenSSL . I just want to run a program using OpenSSL.
下面是我的程序,从这里 拍摄。
Here is my program, taken from here .
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "openssl/aes.h"
int main(int argc, char* argv[])
{
AES_KEY aesKey_;
unsigned char userKey_[16];
unsigned char in_[16];
unsigned char out_[16];
strcpy(userKey_,"0123456789123456");
strcpy(in_,"0123456789123456");
fprintf(stdout,"Original message: %s", in_);
AES_set_encrypt_key(userKey_, 128, &aesKey_);
AES_encrypt(in_, out_, &aesKey_);
AES_set_decrypt_key(userKey_, 128, &aesKey_);
AES_decrypt(out_, in_,&aesKey_);
fprintf(stdout,"Recovered Original message: %s", in_);
return 0;
}
在编译时我因为有相同的错误消息的程序,但解决的办法只要不为我工作。
While compiling the program I got the same error messages as there, but the solution provided there is not working for me.
我仍然得到编译错误。
I am still getting compile error.
$ gcc -I/home/bholanath/Sources/openssl-1.0.1e/include/ op.c -lcrypt
/tmp/ccvHr9Jr.o: In function `main':
op.c:(.text+0x9c): undefined reference to `AES_set_encrypt_key'
op.c:(.text+0xbc): undefined reference to `AES_encrypt'
op.c:(.text+0xd7): undefined reference to `AES_set_decrypt_key'
op.c:(.text+0xf7): undefined reference to `AES_decrypt'
collect2: error: ld returned 1 exit status
$ gcc op.c -lcrypt
/tmp/ccDEZMog.o: In function `main':
op.c:(.text+0x9c): undefined reference to `AES_set_encrypt_key'
op.c:(.text+0xbc): undefined reference to `AES_encrypt'
op.c:(.text+0xd7): undefined reference to `AES_set_decrypt_key'
op.c:(.text+0xf7): undefined reference to `AES_decrypt'
collect2: error: ld returned 1 exit status
任何帮助去除编译错误和运行我的程序将是巨大的。
我使用在Fedora Linux系统GCC。
Any help to remove compilation error and run my program will be great. I am using GCC under Fedora linux.
推荐答案
OpenSSL库名称是 libcrypto
和的libssl
。尝试联系起来。 libcrypt
是的glibc的一部分。
The OpenSSL library names are libcrypto
and libssl
. Try linking them. libcrypt
is part of glibc.
此外,您code是无效。
这篇关于与OpenSSL的链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文