Skip to content

Unable to load native libraries #867

Closed
@mdelz

Description

@mdelz

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

private bool TryLocateNativeAssetInRuntimesFolder(string name, string baseFolder, out string result)

        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;
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions