linux编译链接openssl库,求大神教一下,linux下怎么样链接openssl的动态库

求大神教一下,linux下怎么样链接openssl的动态库

21c92f7342edc52acb5684b0b88bdcec.png程序代码:#include

#include "openssl/bio.h"

#include "openssl/rand.h"

int main(void)

{

char buf[20], *p;

unsigned char out[20], filename[50];

int ret, len;

BIO *print;

RAND_screen();

strcpy(buf, "我的随机数");

RAND_ADD(buf, 20, strlen(buf));

strcpy(buf, "23424d");

RAND_seed(buf, 20);

while(1)

{

ret = RAND_status();

if(ret == 1)

{

printf("seeded enouth!\n");

break;

}

else

{

printf("not enough sedded!\n");

RAND_pool();

}

}

p = RAND_file_name(filename, 50);

if (p == NULL)

{

printf("can not get rand file\n");

return -1;

}

ret = RAND_write_file(p);

len = RAND_load_file(p ,1024);

ret = RAND_bytes(out, 20);

if (ret != 1)

{

printf("err.\n");

return -1;

}

print = BIO_new(BIO_s_file());

BIO_set_fp(print, stdout, BIO_BICLOSE);

BIO_write(print, out, 20);

BIO_write(print, "\n",2);

BIO_free(print);

RAND_cleanup();

return 0;

}这是我程序代码:

我的openssl的地址是:

21c92f7342edc52acb5684b0b88bdcec.png程序代码:root@zjs-bigtree:~# ldd /usr/bin/openssl

linux-gate.so.1 => (0xb7734000)

libssl.so.1.0.0 => /lib/i386-linux-gnu/libssl.so.1.0.0 (0xb76cb000)

libcrypto.so.1.0.0 => /lib/i386-linux-gnu/libcrypto.so.1.0.0 (0xb7520000)

libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7376000)

libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb7371000)

libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb735b000)

/lib/ld-linux.so.2 (0xb7735000)然后是这个样子编译的:~/test/openssl/nine/rand $ gcc rand.c -L/lib/i386-linux-gnu -Icrypto -o rand

rand.c:2:25: 致命错误: openssl/bio.h:没有那个文件或目录

编译中断。求解决方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值