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

System.DllNotFoundException: libveldrid-spirv #5

Closed
tzachshabtay opened this issue Mar 7, 2019 · 9 comments
Closed

System.DllNotFoundException: libveldrid-spirv #5

tzachshabtay opened this issue Mar 7, 2019 · 9 comments

Comments

@tzachshabtay
Copy link

Similar story to: veldrid/veldrid#24 (comment)

Running with mono on mac, and I'm getting:

System.DllNotFoundException: libveldrid-spirv
  at (wrapper managed-to-native) Veldrid.SPIRV.VeldridSpirvNative.CompileGlslToSpirv(Veldrid.SPIRV.GlslCompileInfo*)
  at Veldrid.SPIRV.SpirvCompilation.CompileGlslToSpirv (System.UInt32 sourceLength, System.Byte* sourceTextPtr, System.String fileName, Veldrid.ShaderStages stage, System.Boolean debug, System.UInt32 macroCount, Veldrid.SPIRV.NativeMacroDefinition* macros) [0x0009c] in <6bb6e2dfb45547aabdc0ab126bf5387e>:0 
  at Veldrid.SPIRV.SpirvCompilation.CompileVertexFragment (System.Byte[] vsBytes, System.Byte[] fsBytes, Veldrid.SPIRV.CrossCompileTarget target, Veldrid.SPIRV.CrossCompileOptions options) [0x00029] in <6bb6e2dfb45547aabdc0ab126bf5387e>:0 
  at Veldrid.SPIRV.ResourceFactoryExtensions.CreateFromSpirv (Veldrid.ResourceFactory factory, Veldrid.ShaderDescription vertexShaderDescription, Veldrid.ShaderDescription fragmentShaderDescription, Veldrid.SPIRV.CrossCompileOptions options) [0x0004e] in <6bb6e2dfb45547aabdc0ab126bf5387e>:0 
  at Veldrid.SPIRV.ResourceFactoryExtensions.CreateFromSpirv (Veldrid.ResourceFactory factory, Veldrid.ShaderDescription vertexShaderDescription, Veldrid.ShaderDescription fragmentShaderDescription) [0x00008] in <6bb6e2dfb45547aabdc0ab126bf5387e>:0 
  at AGS.Engine.Desktop.VeldridGraphics.Init () [0x0004d] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine.Desktop/Veldrid/VeldridGraphics.cs:235 
  at AGS.Engine.AGSGame.onGameWindowLoaded (Autofac.TypedParameter settingsParameter, AGS.API.IGameSettings settings) [0x0003b] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/Game/AGSGame.cs:255 
  at AGS.Engine.AGSGame+<>c__DisplayClass89_0.<Start>b__0 (System.Object sender, System.EventArgs e) [0x00001] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/Game/AGSGame.cs:128 
  at AGS.Engine.Desktop.VeldridGameWindow.onShown () [0x00000] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine.Desktop/Veldrid/VeldridGameWindow.cs:137 
  at Veldrid.Sdl2.Sdl2Window.HandleWindowEvent (Veldrid.Sdl2.SDL_WindowEvent windowEvent) [0x00082] in <0cc1ad6b9b954430b07cefd96775c479>:0 
  at Veldrid.Sdl2.Sdl2Window.HandleEvent (Veldrid.Sdl2.SDL_Event* ev) [0x0018f] in <0cc1ad6b9b954430b07cefd96775c479>:0 
  at Veldrid.Sdl2.Sdl2Window.ProcessEvents (Veldrid.Sdl2.SDLEventHandler eventHandler) [0x0002f] in <0cc1ad6b9b954430b07cefd96775c479>:0 
  at Veldrid.Sdl2.Sdl2Window.PumpEvents () [0x00038] in <0cc1ad6b9b954430b07cefd96775c479>:0 
  at AGS.Engine.Desktop.VeldridGameWindow.onRenderFrame (System.Object sender, AGS.Engine.FrameEventArgs e) [0x00015] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine.Desktop/Veldrid/VeldridGameWindow.cs:144 
  at (wrapper delegate-invoke) System.EventHandler`1[AGS.Engine.FrameEventArgs].invoke_void_object_TEventArgs(object,AGS.Engine.FrameEventArgs)
  at AGS.Engine.AGSUpdateThread.RaiseUpdateFrame (System.Double elapsed, System.Double& timestamp) [0x0000e] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/Game/AGSUpdateThread.cs:227 
  at AGS.Engine.AGSUpdateThread.DispatchUpdateFrame () [0x0002c] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/Game/AGSUpdateThread.cs:193 
  at AGS.Engine.AGSUpdateThread.threadLoop () [0x00028] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/Game/AGSUpdateThread.cs:176 
  at AGS.Engine.AGSUpdateThread.Run (System.Double updates_per_second, System.Boolean spawnThread) [0x0008a] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/Game/AGSUpdateThread.cs:165 
  at AGS.Engine.Desktop.VeldridGameWindow.Run (System.Double updateRate) [0x00032] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine.Desktop/Veldrid/VeldridGameWindow.cs:124 
  at AGS.Engine.AGSGame.Start () [0x0019e] in /Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/Game/AGSGame.cs:150 

Worked around it for now by copying the file manually from
~/.nuget/packages/veldrid.spirv/1.0.7/runtimes/osx-x64/native/libveldrid-spirv.dylib

@mellinoe
Copy link
Collaborator

mellinoe commented Mar 7, 2019

Something like this file is needed for mono to work automatically:

https://github.com/mellinoe/veldrid/blob/master/src/Veldrid.SDL2/build/net40/Veldrid.SDL2.targets

@mellinoe
Copy link
Collaborator

I included a build targets file in the latest version (1.0.8) that should fix this.

@tzachshabtay
Copy link
Author

@mellinoe this doesn't seem to work. I'm now getting a compile error:

/Library/Frameworks/Mono.framework/Versions/5.16.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Error MSB3030: Could not copy the file "/Users/zachi/.nuget/packages/veldrid.sdl2/4.5.0/runtimes/osx-x64/native/libveldrid-spirv.dylib" because it was not found. (MSB3030) (MonoQuad)

For some reason it seems to try finding the spirv dylib in the sdl2 directory?

@mellinoe
Copy link
Collaborator

It looks like your NuGet package somehow got messed up. Can you delete the /Users/zachi/.nuget/packages/veldrid.sdl2/ folder and then run restore again (it will be downloaded again). If that doesn't help, please share your project so I can repro it.

@tzachshabtay
Copy link
Author

Doesn't help.
Try compiling the MonoQuad project in this branch (on mac).

@mellinoe
Copy link
Collaborator

@tzachshabtay Sorry about this, there's definitely a problem with how Veldrid.SDL2 and Veldrid.SPIRV interact when they are both referenced from a mono project. Additionally, there's a problem with Veldrid.SDL2 4.5.0 that has been fixed in 4.6.0 that interferes with osx-x64 detection.

The root problem is that both NuGet packages try to define the same _NativeLibName property (and a couple of other "private" properties), and they end up colliding with each other when referenced by the same project. This is why it is seemingly looking for libveldrid-spirv.dylib in the SDL2 package directory. I'll prepare a fix and put out a patch for the NuGet packages so there are no collisions.

@mellinoe mellinoe reopened this Mar 29, 2019
@mellinoe
Copy link
Collaborator

Veldrid.SDL2 4.6.1 and Veldrid.SPIRV 1.0.9 both include fixes to ensure that they won't cause build property collisions anymore. Upgrading one or both should solve your issue. Sorry for the slow fix here; please let me know if anything else is not working correctly.

@tzachshabtay
Copy link
Author

I can confirm that it's working properly now, thank you.

@sherjilozair
Copy link

I'm still facing this issue. I'm using Rider on mac.

Here's my package.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.DotNet.PlatformAbstractions" version="2.0.3" targetFramework="net472" />
  <package id="Microsoft.Extensions.DependencyModel" version="2.0.3" targetFramework="net472" />
  <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net472" />
  <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net472" />
  <package id="NativeLibraryLoader" version="1.0.10" targetFramework="net472" />
  <package id="NETStandard.Library" version="1.6.1" targetFramework="net472" />
  <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net472" />
  <package id="SharpDX" version="4.0.1" targetFramework="net472" />
  <package id="SharpDX.D3DCompiler" version="4.0.1" targetFramework="net472" />
  <package id="SharpDX.Direct3D11" version="4.0.1" targetFramework="net472" />
  <package id="SharpDX.DXGI" version="4.0.1" targetFramework="net472" />
  <package id="System.AppContext" version="4.3.0" targetFramework="net472" />
  <package id="System.Buffers" version="4.4.0" targetFramework="net472" />
  <package id="System.Collections" version="4.3.0" targetFramework="net472" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net472" />
  <package id="System.Console" version="4.3.0" targetFramework="net472" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net472" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net472" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net472" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net472" />
  <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net472" />
  <package id="System.IO" version="4.3.0" targetFramework="net472" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net472" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net472" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
  <package id="System.Linq" version="4.3.0" targetFramework="net472" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net472" />
  <package id="System.Net.Http" version="4.3.0" targetFramework="net472" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="net472" />
  <package id="System.Net.Sockets" version="4.3.0" targetFramework="net472" />
  <package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="net472" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net472" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net472" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net472" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net472" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net472" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.4.0" targetFramework="net472" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net472" />
  <package id="System.Runtime.Handles" version="4.3.0" targetFramework="net472" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net472" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net472" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net472" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net472" />
  <package id="System.Threading" version="4.3.0" targetFramework="net472" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net472" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="net472" />
  <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net472" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net472" />
  <package id="Veldrid" version="4.6.1" targetFramework="net472" />
  <package id="Veldrid.MetalBindings" version="4.6.1" targetFramework="net472" />
  <package id="Veldrid.OpenGLBindings" version="4.6.1" targetFramework="net472" />
  <package id="Veldrid.SPIRV" version="1.0.12" targetFramework="net472" />
  <package id="Vk" version="1.0.21" targetFramework="net472" />
</packages>

I worked around by copying the .dylib from the .nuget directory.

frenzibyte pushed a commit to frenzibyte/veldrid-spirv that referenced this issue Sep 24, 2023
Update iOS deployment workflow to generate framework bundles
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