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

Author Topic: Mac OS X problems with @executable_path/../Frameworks/libsfml-graphics.2.dylib  (Read 6549 times)

0 Members and 1 Guest are viewing this topic.

mgatland

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hi,

I'm trying to get an SFML.Net project from Windows working on a mac (OS X).

I installed Xamarin Studio and Mono.

I downloaded compiled copies of CSFML-2.1-osx-clang-universal and SFML-2.1-osx-clang-universal.

I created caves3.exe from my project.

When I ran it (mono caves3.exe) I got this error:


Code: [Select]
Unhandled Exception: System.DllNotFoundException: csfml-graphics-2
To solve that, I created a file at Users/matthew/.mono/config with this text:

<configuration>
    <dllmap dll="csfml-graphics-2" target="libcsfml-graphics.2.1.dylib" />
    <dllmap dll="csfml-window-2" target="libcsfml-window.2.1.dylib" />
</configuration>
 

And then put libcsfml-graphics.2.1.dylib and libcsfml-window.2.1.dylib in the same folder as caves3.exe

When I run it again mono caves3.exe I get this error:

Code: [Select]
Mono: DllImport unable to load library 'dlopen(libcsfml-graphics.2.1.dylib, 9): Library not loaded: @executable_path/../Frameworks/libsfml-graphics.2.dylib
  Referenced from: /Users/matthew/Documents/projects/caves/caves3/bin/Debug/libcsfml-graphics.2.1.dylib
  Reason: image not found'.

Unhandled Exception:
System.DllNotFoundException: libcsfml-graphics.2.1.dylib

Note that the missing file is libsfml-graphics.2.dylib - the 2.1 file WAS found as I understand.

I have the missing file, libsfml-graphics.2.dylib, from the SFML-2.1-osx-clang-universal.tar.gz download.

But I don't know where to put it.

* Can I override the path "@executable_path/../Frameworks/libsfml-graphics.2.dylib" so I can put the dylib file in the same folder as the .exe file? (that path seems to be hardcoded inside libcsfml-graphics.2.1.dylib)
* Can I put the "missing" libsfml-graphics.2.dylib file somewhere so that mono will find it?
« Last Edit: February 20, 2014, 11:14:09 am by mgatland »

mgatland

  • Newbie
  • *
  • Posts: 2
    • View Profile
I worked it out myself.

You can edit the paths inside the dylib files.

To inspect the paths in a dylib file:

> otool -L libsfml-graphics.2.1.dylib

output:
Code: [Select]

libsfml-graphics.2.1.dylib:
@executable_path/../Frameworks/libsfml-graphics.2.dylib (compatibility version 2.0.0, current version 2.1.0)
@executable_path/../Frameworks/libsfml-window.2.dylib (compatibility version 2.0.0, current version 2.1.0)
@executable_path/../Frameworks/libsfml-system.2.dylib (compatibility version 2.0.0, current version 2.1.0)
@executable_path/../Frameworks/freetype.framework/Versions/A/freetype (compatibility version 17.0.0, current version 17.0.0)
...

I removed the "@executable_path/../Frameworks/" part from each of the paths that had it, making them point to the current directory instead.

e.g.
> install_name_tool -change @executable_path/../Frameworks/libsfml-graphics.2.dylib libsfml-graphics.2.dylib libsfml-graphics.2.1.dylib


Each time I used the otool command again to check.

The first path has now changed:

> otool -L libsfml-graphics.2.1.dylib

output:
Code: [Select]

libsfml-graphics.2.1.dylib:
libsfml-graphics.2.dylib (compatibility version 2.0.0, current version 2.1.0)
@executable_path/../Frameworks/libsfml-window.2.dylib (compatibility version 2.0.0, current version 2.1.0)
@executable_path/../Frameworks/libsfml-system.2.dylib (compatibility version 2.0.0, current version 2.1.0)
@executable_path/../Frameworks/freetype.framework/Versions/A/freetype (compatibility version 17.0.0, current ...

Three more to go. Once all of the "@executable..." paths were replaced, and all the expected files were in the current folder, it worked.



Just for reference, to run the program on Windows requires these files:

Code: [Select]
caves3.exe
csfml-audio-2.dll
csfml-graphics-2.dll
csfml-window-2.dll
libsndfile-1.dll
sfmlnet-audio-2.dll
sfmlnet-graphics-2.dll
sfmlnet-window-2.dll

To run the program on OS X, I needed these files:
Code: [Select]
caves3.exe
freetype.framework
libcsfml-audio.2.1.dylib
libcsfml-graphics.2.1.dylib
libcsfml-window.2.1.dylib
libsfml-audio.2.1.dylib
libsfml-audio.2.dylib
libsfml-graphics.2.1.dylib
libsfml-graphics.2.dylib
libsfml-system.2.1.dylib
libsfml-system.2.dylib
libsfml-window.2.1.dylib
libsfml-window.2.dylib
sfmlnet-audio-2.dll
sfmlnet-audio-2.dll.config
sfmlnet-graphics-2.dll
sfmlnet-graphics-2.dll.config
sfmlnet-window-2.dll
sfmlnet-window-2.dll.config
sndfile.framework

(the three *.config files are an alternative to configuring mono in the  /Users/yourname/.mono/config configuration file.)
« Last Edit: February 21, 2014, 12:09:41 pm by mgatland »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
For future readers, that link should provide some useful information too. https://github.com/pdinklag/JSFML/wiki/Building-JSFML
SFML / OS X developer

paste0x78

  • Newbie
  • *
  • Posts: 2
    • View Profile
...

To run the program on OS X, I needed these files:
Code: [Select]
caves3.exe
freetype.framework
libcsfml-audio.2.1.dylib
libcsfml-graphics.2.1.dylib
libcsfml-window.2.1.dylib
libsfml-audio.2.1.dylib
libsfml-audio.2.dylib
libsfml-graphics.2.1.dylib
libsfml-graphics.2.dylib
libsfml-system.2.1.dylib
libsfml-system.2.dylib
libsfml-window.2.1.dylib
libsfml-window.2.dylib
sfmlnet-audio-2.dll
sfmlnet-audio-2.dll.config
sfmlnet-graphics-2.dll
sfmlnet-graphics-2.dll.config
sfmlnet-window-2.dll
sfmlnet-window-2.dll.config
sndfile.framework


Ah thank you, thank you, thank you. Was trying for hours last night to get this working then I found your post and everything clicked.  :D

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
I find funny the huge number of people not looking at the official doc first..  ::)
SFML / OS X developer

paste0x78

  • Newbie
  • *
  • Posts: 2
    • View Profile
I find funny the huge number of people not looking at the official doc first..  ::)

Ya I seem to have missed this page .. http://www.mono-project.com/Config
"These configuration files work on a per-directory basis" was all I needed.

 

anything