Raylib-cs
Raylib-cs copied to clipboard
DllImport fails find raylib.dll on Windows
Issue description
I followed the manual installation instructions https://github.com/ChrisDill/Raylib-cs#installation---manual
When trying to launch a hello world example from the readme, it couldn't find raylib.dll.
Raylib-cs's build script seems to have copied the runtimes directory (and all dlls within) to the project's build directory, but the exe itself then can't find the dll.
If I copy the dll manually next to the exe, the dll is found and all works.
Environment
OS: Windows 10 Raylib-cs version: tag v4.5.0.4 Raylib version: 4.5.0
Issue screenshot
Unhandled exception. System.DllNotFoundException: Unable to load DLL 'raylib' or one of its dependencies: The specified module could not be found. (0x8007007E)
at Raylib_cs.Raylib.InitWindow(Int32 width, Int32 height, SByte* title)
at Raylib_cs.Raylib.InitWindow(Int32 width, Int32 height, String title) in C:\Users\yanchith\workspace\coderdojo\Raylib-cs-gmae\Raylib-cs\Raylib-cs\types\Raylib.Utils.cs:line 13
at HelloWorld.Program.Main() in C:\Users\yanchith\workspace\coderdojo\Raylib-cs-gmae\gmae\Program.cs:line 9
Code example
Reproduce on Windows 10 by following the manual installation instructions and copying the hello world program from the readme.
I actually have the repro here as well: https://github.com/yanchith/Raylib-cs-gmae (it is a template repository for the kids I teach)
I also have the same problem on macOS, but there even the workaround doesn't help. Should I open a separate issue for that?
@yanchith Thanks for opening the issue. For now I would stick to copying it next to the exe instead when not using the nuget package. I will update the README to make this clearer. Been a known issue for a while in the dotnet sdk https://github.com/dotnet/sdk/issues/19929.
No need for a separate issue. Issue can be tracked here for multiple platforms.
Also worth mentioning that you can try Raylib-cs.Native which aims to build raylib locally and copy next to the executable. Aim is to make manual installation easier however it is a work in progress. You can try it with the Examples project to compare.
Thanks! I'll try out the build-from-source version.
I have a hunch that macOS has some more issues, but'll post back here after I've tried
@yanchith Any update on this issue?
Hi, unfortunately I don't have any updates. I got swamped by other stuff. Meanwhile the kids jumped engines 4 times, so I have no-one urging me to fix it.
Last I remember: the DLL issue on Windows was as we talked before - you had to copy the DLL next to the exe manually. On macOS, even the workaround didn't work. I don't know the library loading system on macOS very well, and gave up on figuring it out after some time.