DesktopGL: MKBundle Issues on Mac

Hey all, so i’ve ported my game to desktop GL, works great on windows and using terminal on mac it also runs fine with ‘mono game.exe’ command.

However when I try to use MKBundle to make a standalone version the resulting file always produces an error that it cant find SDL2.dll

Unhandled Exception:
System.DllNotFoundException: SDL2.dll
  at (wrapper managed-to-native) Sdl:GetVersion (Sdl/Version&)
  at Microsoft.Xna.Framework.SdlGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00030] in <51e93699880c408d953fba691e3e3c74>:0 
  at Microsoft.Xna.Framework.GamePlatform.PlatformCreate (Microsoft.Xna.Framework.Game game) [0x00000] in <51e93699880c408d953fba691e3e3c74>:0 
  at Microsoft.Xna.Framework.Game..ctor () [0x001fb] in <51e93699880c408d953fba691e3e3c74>:0 
  at Drawtopia_Desktop.GameStateManagementGame..ctor () [0x00000] in <a550ce2bbf4b4a0a9a22cc4f1c172467>:0 
  at Drawtopia_Desktop.Program.Main () [0x00000] in <a550ce2bbf4b4a0a9a22cc4f1c172467>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: SDL2.dll
  at (wrapper managed-to-native) Sdl:GetVersion (Sdl/Version&)
  at Microsoft.Xna.Framework.SdlGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00030] in <51e93699880c408d953fba691e3e3c74>:0 
  at Microsoft.Xna.Framework.GamePlatform.PlatformCreate (Microsoft.Xna.Framework.Game game) [0x00000] in <51e93699880c408d953fba691e3e3c74>:0 
  at Microsoft.Xna.Framework.Game..ctor () [0x001fb] in <51e93699880c408d953fba691e3e3c74>:0 
  at Drawtopia_Desktop.GameStateManagementGame..ctor () [0x00000] in <a550ce2bbf4b4a0a9a22cc4f1c172467>:0 
  at Drawtopia_Desktop.Program.Main () [0x00000] in <a550ce2bbf4b4a0a9a22cc4f1c172467>:0 

This is what im doing for the MKBundle in Terminal:

mkbundle --static -o DrawtopiaApp Drawtopia_Desktop.exe --deps --sdk /Library/Frameworks/Mono.framework/Versions/Current

Any suggestions on how to get it to find the SDL2.dll? I can only assume im doing something wrong with the MKBundle since it works using the mono command on the exe.

I have tested with Mac too. But you need copy sdl2.dll from x86 or x64 directory into root directory of exe ( net assembly )

  1. Copy from /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5 into root directory of executable ( net assembly )
  2. Copy from /Library/Frameworks/MonoGame.frameworks/Assemblies/DesktopGL ( x86 or x64 ) to your bin/Debug or /bin/Release
    Check my picture ops it is big because I show you better you find.

And you can check with mkbundle again. than it works sure for you.-

Thanks for the reply, I gave this a try but no dice. Same error. As far as im aware on OSX the MonoGame.FrameWork.dll.config file is pointing it toward the .dylib version of the file anyway which is already included.

config file looks like this:

<?xml version="1.0" encoding="utf-8"?> <configuration> <dllmap dll="SDL2.dll" os="osx" target="libSDL2-2.0.0.dylib"/> <dllmap dll="soft_oal.dll" os="osx" target="libopenal.1.dylib" /> <dllmap dll="SDL2.dll" os="linux" cpu="x86" target="./x86/libSDL2-2.0.so.0"/> <dllmap dll="soft_oal.dll" os="linux" cpu="x86" target="./x86/libopenal.so.1" /> <dllmap dll="SDL2.dll" os="linux" cpu="x86-64" target="./x64/libSDL2-2.0.so.0"/> <dllmap dll="soft_oal.dll" os="linux" cpu="x86-64" target="./x64/libopenal.so.1" /> </configuration>

If I try to add SDL2.dll or the dylib to the MKBundle Assemblies as an attempt to make sure it gets referenced it throws this error.

ERROR: Cannot load assembly (bad file format) Exception of type 'IKVM.Reflection.BadImageFormatException' was thrown.

BUUUUT… if I run the below in terminal it works fine…:
mono Drawtopia_Desktop.exe

Im at a loss as to why it cant be found only after MKBundle :confused:

You should be careful if x86 = Mono 32 bit and x64 = Mono 64 Bit.

Check mono --version than it will output “x64” than you need compile MonoGame into x64
Found Xamarin Studio / Visual Studio 2017 for Mac:

than you can generate again with mkbundle. Please check before mono --version than you know Mac OS X has x64 Bit version. If Mono has not architecture i686.

Remember before “mono --version” than you can build single binary. Good luck!

// EDIT If you have error from xml than you can create before backup of your monogame solution and create new solution again and click right on project name → Options

And find Compiler → Change x86 to x64 and compile again. If Xamarin or Visual Studio doesn’t throws error assembly… If you have upgraded Xammac and Mono frameworks.

Thanks!

So, I gave all of the above a try as suggested. I even brought the whole project over to my Mac and got it running in VS for Mac instead of just sending the release folder from my PC but same issue no matter what I do.

It absolutely refuses to find SDL2 after MKBundle :cry:

Im not sure what else I can try unless I switch to giving MonoKickstart a go instead.

Oh yes don’t worry you need type terminal ./DrawtopiaApp

Example from my bundled app:

It is easy why do you not understand?

I explain you:

do not use --sdk or -L just copy from …/mono/4.5/.dll . ( 4.5 from lib/mono/4.5 )
And copy from MonoGame.frameworks/Assemblies/
.dll .
and change x86 to x64 from tab Compiler and OK
Build / Rebuild project!

And check and from directory x64 to bin/Debug or bin/Release

And generate mkbundle until
If it throws error than you need write gcc …
gcc -ggdb -o DrawtopiaApp -Wall temp.c pkg-config --cflags --libs mono-2 temp.o

And type ./DrawtopiaApp and you see if window of MonoGame shows than it works fine.

It works fine for me. No problem!

If you have problem than I give to other members in MonoGame Community.

PS: Hello dear MonoGame Members please help him and explain him!

Thanks!