question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load native libraries

See original GitHub issue

Hi everyone,

I was debugging why my application is not able to find glfwWindowHintString after updating from silk 1.9 to 2.14

It looks like that DefaultPathResolver.TryLocateNativeAssetInRuntimesFolder appends the name of the library twice.

Expected file to load: bin/Debug/net6.0/runtimes/linux-x64/native/libglfw.so.3 File it tries to load: bin/Debug/net6.0/runtimes/linux-x64/native/libglfw.so.3/libglfw.so.3

I cannot properly debug if this is the root of my problem because moving the file int the directory it expects results in the following build error. Microsoft.Common.CurrentVersion.targets(4808, 5): [MSB3024] Could not copy the file "~/.nuget/packages/ultz.native.glfw/3.3.3.1/runtimes/linux-x64/native/libglfw.so.3" to the destination file "bin/Debug/net6.0/runtimes/linux-x64/native/libglfw.so.3", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.

OS: Ubuntu 18.04 .Net: net6.0

https://github.com/dotnet/Silk.NET/blob/36f3130b2a732b636333f6462704c3882ec0dcdc/src/Core/Silk.NET.Core/Loader/DefaultPathResolver.cs#L203

        private bool TryLocateNativeAssetInRuntimesFolder(string name, string baseFolder, out string result)
        {
            static bool Check(string name, string ridFolder, out string result)
            {
                var theoreticalFName = Path.Combine(ridFolder, name);
                if (File.Exists(theoreticalFName))
                {
                    result = theoreticalFName;
                    return true;
                }

                result = null;
                return false;
            }

            foreach (var rid in GetAllRuntimeIds(RuntimeEnvironment.GetRuntimeIdentifier(), DependencyContext.Default))
            {
                if (Check(name, Path.Combine(baseFolder, "runtimes", rid, "native", name), out result))
                {
                    return true;
                }
            }

            result = null;
            return false;
        }

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Perkseycommented, Mar 29, 2022

Will add this in 2.15, will use this issue to track. Thanks for the suggestion!

0reactions
Perkseycommented, Apr 1, 2022

Note that the new API is intentionally not very accessible, as realistically you probably shouldn’t need to use hacks like this. Especially when doing a release using dotnet publish -c Release -r linux-x64, the correct binary gets put by your executable anyway which I believe libdl will look at first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JNI Unable to load native library - java
That error means that the Java VM is finding and attempting to load your .dll, but additional .dlls that your .dll depends on...
Read more >
How to Fix the Unable to Load NativeHadoop Library for ...
1. Install the Required Native Libraries · 2. Set the Native Library Path · 3. Compile Hadoop on Your System · 4. Use...
Read more >
"Error occurred during initialization of VM", "Unable to load ...
Error occurred during initialization of VM Unable to load native library: The specified procedure could not be found .
Read more >
Workaround for Unable to load native library: libnative ...
Create a java class that subclasses android.app.NativeActivity and load the libnative-activity.so library with System.loadLibrary, in a static ...
Read more >
Unable to load native-hadoop library for your platform ...
Solution 1: Hadoop Native Library Version Mismatch. You will get this warning, If you are running Hadoop on 64bit OS and the native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found