【问题标题】:Undefined reference to `COMP_zlib@libcrypto.so.10' (and others)对“COMP_zlib@libcrypto.so.10”(和其他)的未定义引用
【发布时间】:2016-09-27 10:24:53
【问题描述】:

我正在开发 Red Hat Enterprise Linux Server 7.0 版 (Maipo)。服务器提供 OpenSSL 1.0.1。我在尝试链接到 OpenSSL 时遇到很多加密错误。

这是我的链接命令命令行(命令行中的顺序):

g++ -g -O2 -Wl,-rpath -o output file1.o  libprivate_lib1.so -Lprivate_path -llib1 -ldl \
-lpthread -llib2 -lexpat -lgtest -lgtest_main -lboost_regex -lboost_filesystem -llzma \
-lcrypto private_lib2.so private_lib3.so -llib3

以下是一些错误:

/lib64/libssl.so.10: undefined reference to `COMP_zlib@libcrypto.so.10'
/lib64/libssh2.so.1: undefined reference to `EVP_get_cipherbyname@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `X509_STORE_free@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `BIO_clear_flags@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `d2i_KRB5_AUTHENT@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `MD5_Transform@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `X509_VERIFY_PARAM_set_depth@libcrypto.so.10'
/lib64/libssh2.so.1: undefined reference to `DSA_do_verify@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `SHA384_Init@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `PEM_ASN1_read_bio@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `FIPS_mode@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `OBJ_find_sigid_algs@libcrypto.so.10'
/lib64/libssh2.so.1: undefined reference to `BN_bn2bin@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `EVP_rc2_40_cbc@libcrypto.so.10'
/lib64/libssl.so.10: undefined reference to `sk_num@libcrypto.so.10'
...

当我跑步时:

ll /usr/lib64/libcrypto.so

我来了

/usr/lib64/libcrypto.so -> libcrypto.so.1.0.1e

运行时:

objdump -tT /usr/lib64/libcrypto.so.1.0.1e | grep COMP_zlib

我明白了

000000000013e500 g    DF .text  0000000000000002  libcrypto.so.10 COMP_zlib_cleanup
000000000013e460 g    DF .text  000000000000009e  libcrypto.so.10 COMP_zlib

所以这意味着我在这个图书馆里有它。 最奇怪的是,它能够在 redhat 6.5/4 中链接,但在 redhat 7 以上时失败。 有什么建议么 ?

【问题讨论】:

  • 这个问题不清楚,可能有很多潜在的原因。我们甚至不知道您尝试链接的什么或您正在使用哪些工具的哪个版本,以及您如何使用它们(例如 CLI args)等等。跨度>
  • 也许你忘了链接到 libcrypto ?添加-lcrypto 链接标志之后 用于链接到libssl 的标志。或者,您可能正试图链接一些您在与 Red Hat 7.0 不兼容的机器上编译的不兼容库。无论如何,详细描述您的问题是个好主意,例如向我们展示您运行的产生此输出的实际命令。
  • 我正在链接加密库(添加了命令行)。我认为它与redhat 7有关。因为它能够在redhat 6.5/4上编译。

标签: openssl redhat


【解决方案1】:

COMP_zlibEVP_get_cipherbyname 等函数是 OPenSSL SSL 库的一部分,而不是 Crypto 库的一部分。你有-lcrypto,但你似乎缺少-lssl

g++ -g -O2 -Wl,-rpath -o output file1.o  libprivate_lib1.so -Lprivate_path -llib1 -ldl \
-lpthread -llib2 -lexpat -lgtest -lgtest_main -lboost_regex -lboost_filesystem -llzma \
-lcrypto private_lib2.so private_lib3.so -llib3

你应该改成-lssl -lcrypto:

g++ -g -O2 -Wl,-rpath -o output file1.o  libprivate_lib1.so -Lprivate_path -llib1 -ldl \
-lpthread -llib2 -lexpat -lgtest -lgtest_main -lboost_regex -lboost_filesystem -llzma \
-lssl -lcrypto private_lib2.so private_lib3.so -llib3

如果 private_lib2.so private_lib3.so 依赖于 OpenSSL,则需要将 -lssl -lcrypto 移到它们之后。也就是说,使用private_lib2.so private_lib3.so -lssl -lcrypto

另外libssh 必须继续-lssl -lcrypto。我看不到它的链接位置,但该库可能会使用不同的名称。最后,您可能会发现使用库列表<other libs> ... -lssl -lcrypto -llzma -pthread 会更容易。

也可能是存在更新或不同版本的 OpenSSL,但其配置不同。例如,看起来 Red Hat 删除了压缩 (./configure no-comp ...),但标头引入了 COMP_zlib 之类的符号。

我猜你的下一步是:(1) 显示一个典型的编译命令,(2) 提供 g++ -v 以便我们可以看到标题搜索路径。

要记住的最后一件事是您使用的是g++,因此默认情况下与extern "C++" 关联。可能是缺少习惯的旧 OpenSSL 标头之一:

#ifdef __cplusplus
extern "C" {
#endif

...

#ifdef __cplusplus
}
#endif

我无法访问 Red Hat 服务器,所以我不确定。我使用 CentOS 和 Fedora 测试另一个库,但我知道有时存在差异。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-24
    • 2013-05-04
    • 2021-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多