OSX GCC how to specify sfml library source?

醉酒当歌 提交于 2019-12-03 08:34:19

Why doesn't SFML formula work out of the box?

SFML was built to use freetype and libsndfile frameworks from /Library/Frameworks or from the Frameworks folder in your application bundle.

You can find more technical details here and there.

How can I use SFML on Mac easily?

It's really easy: follow 1:1 the official guide: SFML and Xcode (Mac OS X) (And yes, you can use SFML outside Xcode!)

I really want to use brew formula. How can I fix it?

First, take a good look at this issue. That would give you an overview of the problems with the current naïve formula.

Specifically to you current issue, you will need to use install_name_tool to fix your binaries.

Here is how you can do it for freetype. It's similar for libsndfile.

install_name_tool -change @executable_path/../Frameworks/freetype.framework/Versions/A/freetype /usr/local/lib/libfreetype.dylib /usr/local/Cellar/sfml/2.1/lib/libsfml-graphics.2.1.dylib

However, this means your app will look for freetype in /usr/local/lib. Hence, you would have to install freetype there on your clients' computers too. This is not the case if you use the official installation procedure and use Xcode templates to create a SFML app.

SFML assumes you're building a .app bundle. Notice it's complaining about not finding FreeType, which is a dependency of SFML (it's not complaining about finding SFML). And notice where it's looking for FreeType: @executable_path/../Frameworks/freetype.framework/Versions/A/freetype.

If your program (keeper) is in ., then OS X is looking for FreeType in ./../Frameworks/freetype.framework/Versions/A/freetype, and it's complaining that it can't find it. That because those SFML libraries think you've created a .app bundle, which would then have the necessary/assumed folder structure.

Your options are:

  • Build a .app bundle that includes everything
  • Put the dependencies (FreeType and sndfile) in the right spot manually (i.e. @executable_path/../Frameworks/freetype.framework/Versions/A/freetype)
  • Build SFML yourself and change where/how it looks for its dependencies
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!