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

Unable to load native library #1

Open
tgjones opened this issue Jun 9, 2021 · 3 comments
Open

Unable to load native library #1

tgjones opened this issue Jun 9, 2021 · 3 comments

Comments

@tgjones
Copy link

tgjones commented Jun 9, 2021

This is awesome - thank you so much for creating this library!

As far as I can tell, it's not loading the native library correctly though. When I run SPIRVCross.Test, I get this exception:

Unhandled exception. System.TypeInitializationException: The type initializer for 'SPIRVCross.SPIRV' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'spirv-cross-c-shared.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
   at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String libraryName, Boolean throwOnError)
   at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath)
   at SPIRVCross.LibraryLoader.LoadLocalLibrary(String libraryName) in C:\Users\Tim Jones\Downloads\SPIRV-Cross.NET-main\Src\SPIRVCross\SPIRV.cs:line 57
   at SPIRVCross.SPIRV.LoadNativeLibrary() in C:\Users\Tim Jones\Downloads\SPIRV-Cross.NET-main\Src\SPIRVCross\SPIRV.cs:line 17
   at SPIRVCross.SPIRV..cctor() in C:\Users\Tim Jones\Downloads\SPIRV-Cross.NET-main\Src\SPIRVCross\Generate\Commands.cs:line 17
   --- End of inner exception stack trace ---
   at SPIRVCross.SPIRV.spvc_context_create(spvc_context* context) in C:\Users\Tim Jones\Downloads\SPIRV-Cross.NET-main\Src\SPIRVCross\Generate\Commands.cs:line 96
   at SPIRVCross.Test.Program.Main(String[] args) in C:\Users\Tim Jones\Downloads\SPIRV-Cross.NET-main\Src\SPIRVCross.Test\Program.cs:line 62

I think this is because SPIRVCross.csproj needs to include some extra stuff to copy the native dlls to the output folder. For example, Vortice.Dxc includes a .targets file in the csproj:

https://github.com/amerkoleci/Vortice.Windows/blob/7481411e43659c6e4d25c52b705a7eadcee2cfc2/src/Vortice.Dxc/Vortice.Dxc.csproj#L28-L31

And that .targets file looks like this:

https://github.com/amerkoleci/Vortice.Windows/blob/7481411e43659c6e4d25c52b705a7eadcee2cfc2/src/Vortice.Dxc/build/netstandard2.0/Vortice.Dxc.targets#L6-L12

... unless I'm missing something, and it's working for you without doing that?

@FaberSanZ
Copy link
Owner

Hi ,Sorry for the long delay. Somehow totally missed this. I will try to fix this, but for some reason it works for me

@FaberSanZ
Copy link
Owner

The reason it doesn't work is that I only target .NET 5

@FaberSanZ
Copy link
Owner

I just added support for netstandard2.0, can you try now?

@github-staff github-staff deleted a comment from vokaplok Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@tgjones @FaberSanZ and others