Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
notinghere opened this issue Apr 18, 2024 · 7 comments
Closed

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

notinghere opened this issue Apr 18, 2024 · 7 comments

Comments

@notinghere
Copy link

环境
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
@muyixi315
Copy link

muyixi315 commented Apr 18, 2024

环境 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
Copy link
Author

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

@Jamie-Cui
Copy link
Member

gcc 版本可以看一下嘛?

@usafchn
Copy link
Member

usafchn commented Apr 18, 2024

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

@notinghere
Copy link
Author

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

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

@notinghere
Copy link
Author

gcc 版本可以看一下嘛?

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

@notinghere
Copy link
Author

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

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

@usafchn usafchn mentioned this issue Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants