系统是ubuntu的。在openssl官网上下载了openssl的压缩包,解压后make, make
test, make install都成功了。然后写了一个简单的程序:
#include <stdio.h>
#include <string.h>
#include <openssl/pem.h>
int main()
{
RSA *key;
key = RSA_generate_key(1024, 65537, NULL, NULL);
if (NULL == key){
printf("generate_key error\n");
}
}
可是编译时一直报错说找不到头文件:
可是这个头文件是在的:
求大神带我飞orz
问题解决了
http://www.linuxidc.com/Linux/2011-10/45738.htm 用这个方法把原来的openssl删掉再重装openssl,里面wget的那个1.0.0c
改成1.0.0r。
然后编译时这么写:
sudo gcc -o try try.c -L/usr/local/ssl/include -I/usr/local/ssl/lib -lssl -lcrypto
参考:
http://www.linuxidc.com/Linux/2011-10/45738.htm
http://www.linuxidc.com/Linux/2014-10/108502.htm
编译参数用错了,应该是
-I/usr/local/ssl/include