求大神教一下,linux下怎么样链接openssl的动态库
程序代码:
#include <stdio.h> #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的地址是:
程序代码:
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:没有那个文件或目录 编译中断。求解决方法