I’m changing my code to save and load my game’s save file from the SDL preference path instead of the game folder. I accomplished it with the following:
[DllImport("SDL2", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr SDL_GetPrefPath(string org, string app);
This works perfectly fine on Windows, but on Linux it crashes saying it can’t find SDL2.dll. The game runs with no issues on Linux if I don’t call this method. The same behavior occurs when running it with Mono and with a native Linux executable created via
libSDL2-2.0.so.0 and SDL2.dll are in the x86 and x64 folders, which are in a lib folder directly outside the game executable.
I don’t have much experience with P/Invoke and would greatly appreciate any insight into why SDL2 has no issues loading everything from MonoGame but fails in my game code. Thanks in advance!