-
-
Notifications
You must be signed in to change notification settings - Fork 487
Use pkg-config to detect libnl header and library paths #1698
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cbd9e0f
to
e3c297b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances library detection for libnl by using pkg‑config to determine header and library paths.
- Updates dlopen calls in LibNl.c to prepend LIBNL3_LIBDIR for both libnl‑3 and libnl‑genl‑3 libraries.
- Introduces a new function htop_try_link_libnl3 and integrates pkg‑config checks in configure.ac to correctly set the LIBNL3_LIBDIR and CFLAGS.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
linux/LibNl.c | Updated dynamic loading calls to prepend LIBNL3_LIBDIR, ensuring the correct library search path is used |
configure.ac | Added htop_try_link_libnl3 and pkg‑config-based logic to set up library and header search paths for libnl‑3 |
BenBE
reviewed
May 11, 2025
e3c297b
to
54c9112
Compare
117265b
to
eae13bf
Compare
It no longer requires pkg-config to detect libnl, as the library is now loaded using dlopen(3) (since commit 24b1513).
The delay accounting feature ('--enable-delayacct') should be enabled only if ALL of the netlink/* headers are detected during configure. The current logic has an error that may set enable_delayacct=yes when netlink/handlers.h is not found but netlink/msg.h is found. Fix the logic. Signed-off-by: Kang-Che Sung <[email protected]>
Signed-off-by: Kang-Che Sung <[email protected]>
The libnl3 header search paths may be specified as '-I' options in "libnl-3.0.pc" cflags. This patch can now detect it automatically. The user may set the LIBNL3_CFLAGS environment variable to override pkg-config detection during build. If pkg-config is not available, a default include path "/usr/include/libnl3" will be used. Signed-off-by: Kang-Che Sung <[email protected]>
Introduce LIBNL3_LIBDIR configure variable and preprocessor token to specify a custom path for loading libnl-3 and libnl-genl-3 using dlopen(3). This is helpful when libnl packages are installed in a location outside the default search paths of the libraries. Gentoo and NixOS need this feature to build. User may specify LIBNL3_LIBDIR manually during configure. If it's not specified, configure will try the following in order: (1) find whether libnl exists within the default library search paths by try linking it (LIBNL3_LIBDIR being empty), (2) locate the 'libdir' value of libnl-3.0 package through pkg-config and try linking with the directory included, and (3) if both fail, go back to the default search paths (LIBNL3_LIBDIR being empty) and assume the library doesn't exist during the build but will exist at htop runtime. Co-authored-by: Franz Pletz <[email protected]> Signed-off-by: Kang-Che Sung <[email protected]>
eae13bf
to
08a8910
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
build system 🔧
Affects the build system rather then the user experience
enhancement
Extension or improvement to existing feature
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Supersedes #1637. Fixes #1639.