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

[BUG] GPU compilation should enable the linker flag -ldl by default #730

Closed
rahulaggarwal965 opened this issue Jan 21, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@rahulaggarwal965
Copy link
Contributor

rahulaggarwal965 commented Jan 21, 2024

Describe the bug

On Ubuntu 20.04 (g++-10), when compiling from the v1.3.0 tag (I also tested on main) with GPU_SUPPORT enabled (NVIDIA), the default makefile does not include the linker flag -ldl and therefore does not compile. Adding -ldl solves this problem.

To Reproduce

git clone https://github.com/aristocratos/btop.git
cd btop
git checkout v1.3.0 (optional)
CXX=g++-10 make

I expect the compilation to resolve successfully. Below I have attached a screenshot and a log of the error message.
image

Text Log
/usr/bin/ld: /tmp/btop.c8wIWg.ltrans16.ltrans.o: in function `Shared::init()':
<artificial>:(.text+0x6608): undefined reference to `dlopen'
/usr/bin/ld: <artificial>:(.text+0x6629): undefined reference to `dlopen'
/usr/bin/ld: <artificial>:(.text+0x663e): undefined reference to `dlerror'
/usr/bin/ld: /tmp/btop.c8wIWg.ltrans22.ltrans.o: in function `Gpu::Nvml::init()::{lambda(char const*)#1}::operator()(char const*) const [clone .constprop.0]':
<artificial>:(.text+0x1b6f): undefined reference to `dlsym'
/usr/bin/ld: <artificial>:(.text+0x1b77): undefined reference to `dlerror'
/usr/bin/ld: /tmp/btop.c8wIWg.ltrans22.ltrans.o: in function `Gpu::Rsmi::init()::{lambda(char const*)#1}::operator()(char const*) const [clone .constprop.0]':
<artificial>:(.text+0x1c6f): undefined reference to `dlsym'
/usr/bin/ld: <artificial>:(.text+0x1c77): undefined reference to `dlerror'
/usr/bin/ld: /tmp/btop.c8wIWg.ltrans25.ltrans.o: in function `Gpu::Rsmi::init() [clone .isra.0]':
<artificial>:(.text+0x8497): undefined reference to `dlopen'
/usr/bin/ld: <artificial>:(.text+0x84b1): undefined reference to `dlerror'
/usr/bin/ld: /tmp/btop.c8wIWg.ltrans25.ltrans.o: in function `Gpu::Nvml::shutdown() [clone .isra.0]':
<artificial>:(.text+0x1c19): undefined reference to `dlclose'
/usr/bin/ld: /tmp/btop.c8wIWg.ltrans25.ltrans.o: in function `Gpu::Rsmi::shutdown() [clone .isra.0]':
<artificial>:(.text+0x1ce7): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [Makefile:350: btop] Error 1

However, when I compile using the following command:

LDFLAGS=-ldl make

btop compiles successfully.
image

This seems to be an easy fix, but I would defer to you on whether this fix is only needed on certain platforms/distributions/kernel versions.

Info (please complete the following information):

  • btop++ version: v1.3.0
  • (If compiled) Compiler and version: g++ 10.5.0
  • Architecture: x86_64
  • Platform: Linux
  • (Linux) Kernel: 5.15.0-91-generic
  • Terminal used: st
  • Font used: roboto-mono
@imwints
Copy link
Contributor

imwints commented Jan 22, 2024

Read the README.md and search for similar issues before posting a bug report!

#704 #725

@rahulaggarwal965 rahulaggarwal965 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
@rahulaggarwal965
Copy link
Contributor Author

Since the Makefile doesn't do it I wouldn't like to do this to support (compiling against) some ancient glibc.
Being written with C++-20 btop is dependent on recent compilers anyway so it wouldn't make much sense to support (compiling against) older libc's while requiring new compilers.

Sounds good. Since it looks like you want to have this behavior explicitly, I will close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants