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

DllImport should not be prefixed with lib #463

Closed
jasoncouture opened this issue Jan 30, 2024 · 1 comment · Fixed by #465
Closed

DllImport should not be prefixed with lib #463

jasoncouture opened this issue Jan 30, 2024 · 1 comment · Fixed by #465
Labels
enhancement New feature or request

Comments

@jasoncouture
Copy link
Contributor

jasoncouture commented Jan 30, 2024

The usage of [DllImport("libllama")] results in the windows binaries being prefixed with "lib".
The native libraries in the NuGet packages have renamed DLLs. This makes it annoying to copy in llama binary releases for windows, for testing purposes. If the DLL imports were replaced with just [DllImport("llama")], this issue would not exist on windows, and on other platforms libllama.so and dylibs would work too, even with the lib prefix.

From: https://learn.microsoft.com/en-us/dotnet/standard/native-interop/native-library-loading

When running on Windows, the DLL is searched for in the following order:

nativedep
nativedep.dll (if the library name does not already end with .dll or .exe)

When running on Linux or macOS, the runtime will try prepending lib and appending the canonical shared library extension. On these OSes, library name variations are tried in the following order:

nativedep.so / nativedep.dylib
libnativedep.so / libnativedep.dylib
nativedep
libnativedep

@jasoncouture
Copy link
Contributor Author

jasoncouture commented Jan 30, 2024

This change would require the NuGet llama native binaries get renamed back to llama.dll for windows.

The reason I chose to bring this up, is I'm annoyed by having to remember to rename the dll. I'm trying to get OpenCL/ROCm working, as I don't have, nor do I want an nvidia GPU.

jasoncouture added a commit to jasoncouture/LLamaSharp that referenced this issue Jan 30, 2024
This results in windows users not needing to rename the DLL. This allows native llama builds to be dropped in, even on windows.

I also took the time to update the documentation, removing references to renaming the files, since the names now match.

Fixes SciSharp#463
@martindevans martindevans added the enhancement New feature or request label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants