secretflow / yacl

YACL (Yet Another Common crypto library) is a C++ library that contains cryptography, network and io modules which other SecretFlow code depends on.
https://www.secretflow.org.cn/en/docs/yacl/main/
Apache License 2.0
77 stars 64 forks source link

编译问题报错 ld.lld: error: undefined symbol: dlopen #313

Closed notinghere closed 6 months ago

notinghere commented 6 months ago

环境 Distributor ID: Linuxmint Description: Linux Mint 20.3 Release: 20.3 Codename: una

根据 CHANGELOG 之前编译 - [YACL] v0.4.2 没有问题。 现在编译

ERROR: /home/ll/src/opensrc/yacl/yacl/base/BUILD.bazel:144:13: Linking yacl/base/dynamic_bitset_test failed: (Exit 1): gcc failed: error executing command (from target //yacl/base:dynamic_bitset_test) /usr/local/bin/gcc @bazel-out/k8-opt/bin/yacl/base/dynamic_bitset_test-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld.lld: error: undefined symbol: dlopen
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_globallookup) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_load) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dlsym
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_globallookup) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_bind_func) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dlclose
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_globallookup) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_load) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_unload) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dladdr
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_pathbyaddr) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dlerror
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_pathbyaddr) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_bind_func) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_load) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
collect2: error: ld returned 1 exit status
INFO: Elapsed time: 127.884s, Critical Path: 30.93s
INFO: 300 processes: 142 internal, 158 linux-sandbox.
FAILED: Build did NOT complete successfully
muyixi315 commented 6 months ago

环境 Distributor ID: Linuxmint Description: Linux Mint 20.3 Release: 20.3 Codename: una

根据 CHANGELOG 之前编译 - [YACL] v0.4.2 没有问题。 现在编译

  • [Tag] release/0.4.3 这个版本就存在下面的问题
ERROR: /home/ll/src/opensrc/yacl/yacl/base/BUILD.bazel:144:13: Linking yacl/base/dynamic_bitset_test failed: (Exit 1): gcc failed: error executing command (from target //yacl/base:dynamic_bitset_test) /usr/local/bin/gcc @bazel-out/k8-opt/bin/yacl/base/dynamic_bitset_test-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld.lld: error: undefined symbol: dlopen
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_globallookup) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_load) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dlsym
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_globallookup) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_bind_func) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dlclose
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_globallookup) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_load) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_unload) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dladdr
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_pathbyaddr) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a

ld.lld: error: undefined symbol: dlerror
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_pathbyaddr) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_bind_func) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
>>> referenced by dso_dlfcn.c
>>>               libcrypto-lib-dso_dlfcn.o:(dlfcn_load) in archive bazel-out/k8-opt/bin/external/com_github_openssl_openssl/openssl/lib/libcrypto.a
collect2: error: ld returned 1 exit status
INFO: Elapsed time: 127.884s, Critical Path: 30.93s
INFO: 300 processes: 142 internal, 158 linux-sandbox.
FAILED: Build did NOT complete successfully

我用了secretflow/ubuntu-base-ci:latest,编译测试都是正常通过,目前没发现该问题。

notinghere commented 6 months ago

我现在就是直接下载 yacl , 使用 bazel build //... -c opt 命令编译。

Jamie-Cui commented 6 months ago

gcc 版本可以看一下嘛?

usafchn commented 6 months ago

命令行 bazel build 加个 --linkopt=-ldl 参数试试

notinghere commented 6 months ago

命令行 bazel build 加个 --linkopt=-ldl 参数试试

试了试,行,大佬吊。 尝试在好几个地方加这个参数,都没成功。还得多学bazel.

notinghere commented 6 months ago

gcc 版本可以看一下嘛?

谢谢大佬,楼下大佬方法已经可以了。

notinghere commented 6 months ago

命令行增加 --linkopt=-ldl 即可。

bazel build --linkopt=-ldl //... -c opt