SFML community forums

Bindings - other languages => DotNet => Topic started by: Radnen on July 31, 2013, 04:17:39 am

Title: Mono with OSX
Post by: Radnen on July 31, 2013, 04:17:39 am
So I'm having trouble getting SFML to run under Mono on OSX. I added config files to the dlls, but I don't know if I did it right.

I add csfml-graphics-2.dll.config to the exe directory, and add the libsfml-graphics.2.dylib to it.
The config looks like this:
<configuration>
    <dllmap dll="csfml-window-2.dll.config" target="libsfml-graphics.2.dylib">
</configuration>
 

It should work; any ideas?
Title: Re: Mono with OSX
Post by: Laurent on July 31, 2013, 07:45:12 am
And what happens?
Title: Re: Mono with OSX
Post by: Radnen on July 31, 2013, 07:50:21 am
The standard DLLNotFoundException: "csfml-graphics-2.dll". I thoroughly read through the dllmap tutorial on the mono website and the above *should* work.

Now the only other change I made is to use the name you used in the DllImport sections:
<configuration>
    <dllmap dll="csfml-graphics-2" target="libsfml-graphics.2.dylib" />
</configuration>
 

But that is not working. It doesn't even attempt to load the dylib or dll. I put the dylib file into the same folder as the executable, btw.

Edit: I got somewhere!

I added the config to the sfml-graphics-2.dll file instead and it now looks for the correct dylib file. But now I'm again getting a DllNotFoundException on the dylib file... hmm maybe a misspelling? I'm getting closer.

Edit: impossible.
Mono: DllImport error loading library '/Users/user/code/Engine/Engine/bin/Debug/libsfml-graphics.2.dylib': 'dlopen(/Users/user/code/Engine/Engine/bin/Debug/libsfml-graphics.2.dylib, 9): image not found'.

That is the exact path where the dylib is!! What is going on here!?

Edit:
I realized it was libsfml-graphics.2.0.dylib. I made that change... and still it complains that it doesn't exist.

Okay.. now I have this:
Mono: DllImport unable to load library 'dlopen(libsfml-graphics.2.0.dylib, 9): Library not loaded: @executable_path/../Frameworks/libsfml-window.2.dylib
  Referenced from: /Users/user/code/Engine/Engine/bin/Debug/libsfml-graphics.2.0.dylib
 
Title: Re: Mono with OSX
Post by: Hiura on July 31, 2013, 10:41:23 am
Not that I know anything about Mono but
Quote
I realized it was libsfml-graphics.2.0.dylib. I made that change...
Did you do the same for the window, system and audio module ?
Title: Re: Mono with OSX
Post by: Radnen on July 31, 2013, 11:59:23 am
Yes, I did the same for them. I noticed in the lib folder of the OSX 2.0 binary release that there are libsfml-graphics.2.0.dylib and libsfml-graphics.2.dylib. I don't understand the difference. Also the error I'm getting:

Mono: DllImport unable to load library 'dlopen(libsfml-graphics.2.0.dylib, 9): Library not loaded: @executable_path/../Frameworks/libsfml-window.2.dylib
  Referenced from: /Users/user/code/Engine/Engine/bin/Debug/libsfml-graphics.2.0.dylib
 

Seems to suggest that the mono libraries call other stuff from another library and I don't know where to begin with resolving that. For example, in the libsfml-window-2.0.dylib, libsfml-system.2.dylib is referenced but really not used by the .Net files. I begin to wonder if SFML.net is OSX compatible? I remember getting SFML.net to work in Linux by using .so files, but this seems different.[/code]
Title: Re: Mono with OSX
Post by: zsbzsb on July 31, 2013, 01:01:11 pm
Mono: DllImport unable to load library 'dlopen(libsfml-graphics.2.0.dylib, 9): Library not loaded: @executable_path/../Frameworks/libsfml-window.2.dylib
  Referenced from: /Users/user/code/Engine/Engine/bin/Debug/libsfml-graphics.2.0.dylib
 

Unless I am totally mistaken, but SFML.NET does not use the SFML but rather it uses CSFML. So trying to tell mono to load a C++ dll is not going to work too well. I think you need to build CSFML and then tell mono to load that instead.
Title: Re: Mono with OSX
Post by: Hiura on July 31, 2013, 01:05:08 pm
@Radnen, if you think the issue comes from the load path (@executable_path), look at JSFML building instruction. Maybe you need to do the same. https://github.com/pdinklag/JSFML/wiki/Building-JSFML
Title: Re: Mono with OSX
Post by: Laurent on July 31, 2013, 01:16:33 pm
Quote
SFML.NET does not use the SFML but rather it uses CSFML
Good catch! I didn't notice he was trying to map CSFML DLLs to SFML dylibs.
Title: Re: Mono with OSX
Post by: Radnen on July 31, 2013, 08:12:34 pm
Hmm, so those dylib files were the C++ source! :P

So I guess I have to build the csfml source into dylib files and use that.

Edit: same issue,
Mono: DllImport error loading library 'libcsfml-window.2.0.dylib': 'dlopen(libcsfml-window.2.0.dylib, 9): Library not loaded: @executable_path/../Frameworks/libsfml-window.2.dylib
  Referenced from: /Users/user/code/Engine/Engine/bin/Debug/libcsfml-window.2.0.dylib
  Reason: image not found'.
 
Title: Re: Mono with OSX
Post by: Hiura on July 31, 2013, 08:23:50 pm
My last comment doesn't apply only to SFML. You need to play around with install_name or something.
Title: Re: Mono with OSX
Post by: Radnen on July 31, 2013, 11:40:09 pm
I don't understand. I would first need to obtain a file named: libsfml-window.2.dylib

For me to even play around. I don't see that file anywhere in the sources... Well I do but it's like 1kb and I don't think it's even a proper dylib... right? I put it into ../Frameworks/ folder and still nothing happens.