Ian Schwabe Ian Schwabe - 4 years ago 148
C Question

ioquake3 on MacOS: Bundling Freetype With Game

I'm making a game based on ioquake3, and I enabled the use of Freetype for rendering fonts in the game.

However, that library has been a sore on my back throughout the development, and now the game doesn't run right on MacOS computers besides my own because they don't have Freetype installed.

It will look for "renderer_opengl2_x86_64.dylib" in "." and fail. Yet ioquake3 runs just fine on the same computer. And if I transfer ioquake3.app's renderer dylibs, the game runs but without the text rendering because Freetype isn't enabled by default.

So my question is how I would be able to bundle Freetype with my ioquake3-based game. I thought it would be as simple as copying libfreetype.6.dylib into [game].app/Contents/MacOS , but that didn't work either. The original game doesn't use it so copying the renderer dylibs didn't work. I don't want every user to have to install Freetype and link it and all that, so how do I get the library bundled with my app?

Answer Source

OK, so I found out that the renderer dylib files were calling on a hard-coded directory in the system, a directory I had to map myself to get the game to compile but otherwise is not on a normal MacOS computer.

So what I did was use install_name_tool in Terminal to change the directory the dylibs searched in.

install_name_tool -change /usr/local/lib/libfreetype.6.dylib @executable_path/libfreetype.6.dylib /Applications/{game name}.app/Contents/MacOS/renderer_opengl2_x86_64.dylib

^ Then the same thing for the OpenGL 2 dylib, and I copied the libfreetype.6.dylib file into the Contents/MacOS directory of my app. After that, the game ran perfectly on my computer and the "guinea pig" computer I used that didn't have Freetype installed.

I hope this might help anyone else having issues with Freetype and ioquake3!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download