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

/usr/lib64/libdl.so.2, but no libdl.so #1

Closed
zcsizmadia opened this issue Oct 29, 2019 · 6 comments
Closed

/usr/lib64/libdl.so.2, but no libdl.so #1

zcsizmadia opened this issue Oct 29, 2019 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@zcsizmadia
Copy link

In CentOS 7 /usr/lib64/libdl.so.2 exists, but not libdl.so. To resolve the issue, I created a symlink to /usr/lib64/libdl.so.2 as /usr/lib64/libdl.so.

Is there a better way to solve this, maybe addig libdl.so.2 to the Posix NativeMethods module?

Thanks!

@ied206
Copy link
Owner

ied206 commented Oct 29, 2019

Thanks for trying my library and testing it out. As a quick fix, I will separate Linux code and macOS.

The issue turns out quite complicated due to the fragmentation of linux userspace library location and naming. Originally I have used libdl.so.2, but it was changed to libdl to support Linux and macOS with one code (macOS offers only libdl.dylib).

Solutions

(Fastest) Separate Linux/macOS from shared POSIX code

Copy and paste DllImported libdl function definitions into two. One for Linux (libdl.so.2), and the other for macOS (libdl.dylib).

Pros: Fastest way to solve.
**Cons: ** We have to do similar things per target platform.

Use .Net Core's NativeLibrary class

.Net Core 3.0 offers the new class, NativeLibrary, which solves this problem entirely. I have considered using it but was unable to. The API does not exist in .Net Standard, and shipping .Net Core assembly directly and keeping its forward-compatibility is hard.

Zstandard.Net have similar pull request. I will review their code.

Pros: Now the .Net Core runtime is responsible for exposing native library loading functionality. We can expect that Microsoft will take care of such fragmentation things.
Cons: Only available after .Net Core 3.0. .Net Core does not 100% guarantee the behavior compatibility of APIs over major update, unlike .Net Standard.

Study how .Net Core runtime solved it

.Net Core team must have faced similar problems while implementing DllImport for Linux. I will review the code of CoreFX in the long run.

ied206 added a commit that referenced this issue Oct 29, 2019
Some Linux distributions do not have libdl.so, only having libdl.so.2.
In the contrast, macOS only has libdl.dylib, as described in #1.

To solve the issue, split Linux and macOS libdl DllImport.
@ied206
Copy link
Owner

ied206 commented Oct 29, 2019

I patched the libdl DllImport code in commit b26e4ca.

If you would, please clone the develop branch and run the test (dotnet test) on CentOS.

@ied206 ied206 self-assigned this Oct 31, 2019
@ied206 ied206 added the bug Something isn't working label Oct 31, 2019
@ied206
Copy link
Owner

ied206 commented Oct 31, 2019

The updated package was uploaded to NuGet. It should work on CentOS, please try it.

@zcsizmadia
Copy link
Author

Thanks for the update!

Compression.XZ is still referencing DynLoader 1.2.0, so I had to force to use the latest 1.2.1. After adding the PackageReference DybLoader 1.2.1 to the Compression.XZ.Test the test passed on CentOS 7.

@ied206
Copy link
Owner

ied206 commented Oct 31, 2019

Yes, I also am working on other libraries which depends on Joveler.DynLoader.

@ied206
Copy link
Owner

ied206 commented Oct 31, 2019

Joveler.Compression.XZ and its siblings were updated to reference Joveler.DynLoader 1.2,1. Please have a look.

@ied206 ied206 closed this as completed Nov 23, 2019
hoffmann-stefan added a commit to hoffmann-stefan/ros2_dotnet that referenced this issue Apr 15, 2023
This should fix builds on ubuntu-22.04.
- see https://stackoverflow.com/a/75855054
- see ied206/Joveler.DynLoader#1 for other dotnet library with the same issue
hoffmann-stefan added a commit to hoffmann-stefan/ros2_dotnet that referenced this issue Apr 16, 2023
This should fix builds on ubuntu-22.04.
- see https://stackoverflow.com/a/75855054
- see ied206/Joveler.DynLoader#1 for other dotnet library with the same issue
hoffmann-stefan added a commit to hoffmann-stefan/ros2_dotnet that referenced this issue Apr 20, 2023
This should fix builds on ubuntu-22.04.
- see https://stackoverflow.com/a/75855054
- see ied206/Joveler.DynLoader#1 for other dotnet library with the same issue
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

No branches or pull requests

2 participants