【问题标题】:OpenSSL compile error undefined referenceOpenSSL 编译错误未定义参考
【发布时间】:2020-12-14 15:23:14
【问题描述】:

当我尝试编译 openssl 时出现以下错误。我正在使用 bazel 并且正在使用 gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0。我正在使用 Openssl 1.1.1i。

util/netevent.c:1062: error: undefined reference to 'SSL_get1_peer_certificate'
util/netevent.c:1088: error: undefined reference to 'SSL_get1_peer_certificate'
collect2: error: ld returned 1 exit status

这是我为包装 openssl 编写的 BUILD 文件。以前也是这样,所以我不确定为什么会发生变化。

package(default_visibility = ["//visibility:public"])

cc_library(
 name = "libssl",
 srcs = glob(["**/libssl.a"]),
 hdrs = glob(["**/ssl/**/*.h"])
)

cc_library(
 name = "libcrypto",
 srcs = glob(["**/libcrypto.a"]),
 hdrs = glob(["**/crypto/**/*.h"])
)

OpenSSL 配置为

Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1i (0x1010108fL) for linux-x86_64

我正在链接 -lssl 和 -lcrypto。

我认为问题出在我正在使用的库上,因为它会构建并以某种方式获得 SSL_get1_peer_certificate 而不是 SSL_get_peer_certificate

我 greped 并且它构建的实际文件使用了正确的函数,但二进制文件有错误的函数...

【问题讨论】:

    标签: openssl bazel monero


    【解决方案1】:

    libssl.a 听起来像一个静态库。

    要编译 OpenSSL 库,我希望有一个如下所示的规则

    cc_library(
      name = "libssl",
      srcs = glob(["src/ssl/*.cc"]),
      hdrs = glob(["src/ssl/*.h"]),
      deps = [
        # TODO
      ]
    )
    

    【讨论】:

      【解决方案2】:

      好的,这只是一个奇怪的答案,但我会提供它。一个名为 unbound 的依赖项被静态链接,需要动态链接。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-25
        • 1970-01-01
        • 2023-03-13
        • 2022-10-15
        • 1970-01-01
        • 2015-06-25
        • 2023-03-14
        相关资源
        最近更新 更多