找不到libcrypto库错误 [英] Cannot find libcrypto library error

查看:1082
本文介绍了找不到libcrypto库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图编译 C code,它使用OpenSSL的'密码'的库函数与COMAND行 -lcrypto GCC 4.4.3 它给出了一个错误

When i am trying to compile a C code which uses openssl 'crypto' library functions with comand line -lcrypto with gcc 4.4.3 it gives an error

`@ubu:$ gcc -ggdb aes_m.c -Werror -Wall -I /usr/local/ssl/include/ -lcrypto -o aes
 /usr/bin/ld: cannot find -lcrypto
 collect2: ld returned 1 exit status`

什么可以做的原因?

what can be the reason for this??

我已经通过这个讨论, LD去了也找不到一个现有的库但这并没有帮助。

I have already gone through this discussion ld cannot find an existing library but that does not help.

定位命令结果

$ locate libcrypto
/home/abhi/Downloads/openssl-1.0.1b/libcrypto.a
/home/abhi/Downloads/openssl-1.0.1b/libcrypto.pc
/lib/libcrypto.so.0.9.8
/lib/i486/libcrypto.so.0.9.8
/lib/i586/libcrypto.so.0.9.8
/lib/i686/cmov/libcrypto.so.0.9.8
/usr/lib/libcrypto.so.0.9.8
/usr/lib/vmware-tools/lib32/libcrypto.so.0.9.8
/usr/lib/vmware-tools/lib32/libcrypto.so.0.9.8/libcrypto.so.0.9.8
/usr/lib/vmware-tools/lib64/libcrypto.so.0.9.8
/usr/lib/vmware-tools/lib64/libcrypto.so.0.9.8/libcrypto.so.0.9.8
/usr/local/ssl/lib/libcrypto.a
/usr/local/ssl/lib/pkgconfig/libcrypto.pc

可有人请在此帮助或指出任何错误,我在做什么。

Can someone please help on this or point out any mistake i am doing

@丹尼尔·罗特利斯伯格使用-L标志尝试,但导致产生这些错误

@ Daniel Roethlisberger tried using the -L flag but that resulted in these errors

gcc -ggdb aes_m.c -Werror -Wall -I /usr/local/ssl/include/ -L /usr/local/ssl/lib -lcrypto -o aes
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x2d): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x43): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x4d): undefined reference to `dlclose'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x8f): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0xe9): undefined reference to `dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x4b1): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x590): undefined reference to `dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x611): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x6f0): undefined reference to `dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x755): undefined reference to `dlclose'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x837): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x8ae): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x8f5): undefined reference to `dlerror'
collect2: ld returned 1 exit status

非常感谢

推荐答案

添加 -L的/ usr /本地/ SSL / lib目录/ 进入GCC命令行之前, -lcrypto 。既然你是在建立针对OpenSSL的头的/ usr /本地/ SSL ,你也需要同样的preFIX下对实际库链接(即使只有你似乎有一个静态安装在这里,这可能是也可能不是你的意图。您可能需要适当地重新安装OpenSSL的从源代码构建)

Add -L /usr/local/ssl/lib/ into the GCC command line, before the -lcrypto. Since you are building against the OpenSSL headers under /usr/local/ssl, you also need to link against the actual library under the same prefix (even though you only appear to have a static one installed there, that may or may not be your intention; you may need to properly reinstall your OpenSSL built from source).

(编辑)厘定的dlopen()并没有被链接器发现的朋友,加入 -ldl 到GCC命令行。 -ldl 告诉连接器还针对链接libdl.so,这是包含共享库的dlopen()则dlsym() dlclose()等;这些功能由OpenSSL的内部使用,因此, -ldl 是一种间接的依赖时使用 -lcrypto (在Linux上) 。因为要链接到libcrypto的静态版本,你需要明确地反对所有的间接依赖关系联系起来。

(edit) To fix the dlopen() and friends not being found by the linker, add -ldl into the GCC command line. -ldl tells the linker to also link against libdl.so, which is the shared library containing dlopen(), dlsym(), dlclose() etc.; these functions are used by OpenSSL internally and thus, -ldl is an indirect dependency when using -lcrypto (on Linux). Because you are linking to a static version of libcrypto, you need to explicitly link against all indirect dependencies.

如果您不熟悉的链接到相应的库,我建议你使用OpenSSL从操作系统包管理器安装;它可能会为您节省一些麻烦。

If you are not familiar with linking to the proper libraries, I'd suggest you use OpenSSL as installed from your Operating System package manager; it might save you some trouble.

这篇关于找不到libcrypto库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆