Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Has anyone had any luck getting SFML.NET on .NET Core running on MacOS?  (Read 2037 times)

0 Members and 1 Guest are viewing this topic.

ashley

  • Newbie
  • *
  • Posts: 6
    • View Profile
I was pretty excited about the migration to .NET Core (/standard?), and now I can build on any OS perfectly, which is fantastic as I can run CI on Linux now, but as soon as I try to actually run anything linking to SFML, the runtime linking fails on MacOS and Linux. This is true of examples, my own project, and a test project I set up to try to diagnose with a minimal example.

Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'libcsfml-graphics.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibcsfml-graphics.dylib.dylib, 1): image not found

One thing I found curious is that "dlopen(liblibcsfml-graphics.dylib.dylib)" call. It seems to me that the DllImport is prepending lib and appending .dylib of its own accord, so I tried removing the "lib" and ".dylib" from the const string in SFML.NET and rebuilding. This results in "dlopen(csfml-graphics)" which I find strange -- the appending seems to be conditional on it already being of the correct form.

I'm not sure if this is normal, but it seems very strange to me. In any case, I tried putting copies of the dylib file with all sorts of names - "csfml-graphics", "libcsfml-graphics.dylib" and "liblibcsfml-graphics.dylib.dylib" for good measure. It doesn't seem to find any of these, even though it correctly finds the corresponding DLLs on Windows in the same directory (I have these libraries in the execution directory in project-path/bin/.../).

I've spent quite a lot of time digging and playing around, but I'm not really getting anywhere, so I was wondering if anyone else has invested some time into running new builds on SFML.NET on MacOS without Mono? If so, I'd appreciate some pointers on how to get it working at runtime!

If no-one has gotten it working, but someone has some time and fancies helping, I'm happy to provide more information and a sample project.

Thanks in advance for any help and pointers!

rustybox

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Has anyone had any luck getting SFML.NET on .NET Core running on MacOS?
« Reply #1 on: January 06, 2019, 03:43:26 pm »
Yes it works fine in dev if I set DYLD_PRINT_LIBRARIES and DYLD_PRINT_FRAMEWORKS.

When you release you will be creating an app package with an osx/ folder into which you can put your dependencies.

Just set the environment variables for now.

ashley

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Has anyone had any luck getting SFML.NET on .NET Core running on MacOS?
« Reply #2 on: January 07, 2019, 07:02:24 pm »
Thanks for the reply!

Setting these environment variables just gets me a more verbose version of the same error, terminating in:

dyld: loaded: /Users/ashley/RiderProjects/SFML.NET Test/SFML.NET Test/bin/Debug/netcoreapp2.2/libcsfml-window.dylib
dyld: unloaded: /Users/ashley/RiderProjects/SFML.NET Test/SFML.NET Test/bin/Debug/netcoreapp2.2/libcsfml-window.dylib
dyld: loaded: libcsfml-window.dylib
dyld: unloaded: libcsfml-window.dylib

Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'libcsfml-window.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibcsfml-window.dylib.dylib, 1): image not found
   at SFML.Window.VideoMode.sfVideoMode_getDesktopMode()
   at SFML.Window.VideoMode.get_DesktopMode() in /Users/ashley/SFML.Net/src/Window/VideoMode.cs:line 86
   at SFML.NET_Test.Program.Main(String[] args) in /Users/ashley/RiderProjects/SFML.NET Test/SFML.NET Test/Program.cs:line 12


I wonder if one of my libraries is at the wrong version -- are you using builds of CSFML 2.5? I've tried 2.1, 2.2 and 2.5 and all of them seem to result in this issue for me.

Additionally, I don't have any other libraries in that folder outside of the SFML ones; are you including any openal dylibs or anything?

ashley

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Has anyone had any luck getting SFML.NET on .NET Core running on MacOS?
« Reply #3 on: September 16, 2019, 01:04:04 am »
Necro, but it seems in retrospect I was just using the wrong Nuget packages.

The correct ones are currently SFML.{Net/System/...}/2.5.0.

For others in the same situation later, check the date of release of the Nuget packages and make sure you're not using years old ones!
« Last Edit: September 16, 2019, 01:09:54 am by ashley »