iDevGames Forums
Using FTGL in XCode - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Using FTGL in XCode (/thread-6249.html)

Using FTGL in XCode - IBethune - Sep 14, 2004 01:14 AM

I have had a search through the forums, but no-one seems to have had exactly the same problem as I have - probably because I don't 100% understand what I am doing.

So I have built libfreetype.a using configure & make, as I couldn't get the .pbproj to build correctly, since it was inconsistent with the source files.

I built libftgl.a (or whatever it's called) using the supplied XCode project, but in order to get it to build I had to add all the headers in the 'include' directory of freetype to the project.

Now I want to use FTGL in my own project, so I added libfreetype.a and libftgl.a to the project. Now I'm not sure what to do with headers? I tried adding the headers from both freetype and ftgl, but when doing include "ftgl.h" it can't find the file, I have tried using include <> and also using include/ftgl.h but I get various different errors, including: include expects <FILENAME> or "filename", and various other errors that I can't quite remember as I'm not at the same computer just now.

Anybody know the correct process for doing this?


- Iain

Using FTGL in XCode - Josh - Sep 14, 2004 06:48 AM

You need to run "make install" for FreeType, and then put the FTGL headers in your header search path.

Using FTGL in XCode - IBethune - Sep 14, 2004 06:51 AM

I guess that would work, but I would like to have FTGL & Freetype bundled within my application, so having the user install the libraries is not an option.

- Iain

Using FTGL in XCode - Josh - Sep 14, 2004 07:26 AM

AFAIK, make install just copies the headers to the default header search paths. Nothing stops you from bundling FreeType and FTGL with it.

Using FTGL in XCode - IBethune - Sep 14, 2004 08:11 AM

oh yeah, sorry, I misunderstood. I will have a play with this when I go home from work.

- Iain

Using FTGL in XCode - henryj - Sep 14, 2004 04:20 PM

If you run make in the freetype directory it will build a static library called libfreetype.a. This file is hidden away and is a bit hard to find. From memory it is in .lib or objs/.lib (guess you found it).

Then you need to point the FTGL project at this library and the freetype includes so that you can build libftgl.a, another static library. This has to be done manually because they could be anywhere.

Then copy both of these libraries into YOUR project and point your project at each of the include directories. You can do this by dragging the directories into your project or by setting up the header paths in the compiler settings. Depending on how you built freetype you may also have to link against libz, but this is a standard library on osx so your don't have to do anything special for this.

Finally add a copy files build phase to copy the 2 static libraries into your app bundle.

Using FTGL in XCode - lightbringer - Sep 15, 2004 08:43 AM

henryj Wrote:Finally add a copy files build phase to copy the 2 static libraries into your app bundle.

Um. Static libraries are designed to be built into the executable, this way the user doesn't have to install anything extra and you don't have to include anything extra in the bundle. Just add the path to the static lib in your linker flags and you should be all set.

Using FTGL in XCode - Simon Schoelly - Oct 6, 2004 09:42 AM

I can't get freetype to work.
1. I run make in the freetype folder
2. I run make install in the freetype folder
3. I open my Xcode project and drag libfreetype.a and the the folder freeytpe(from freetype-2.1.9/nclude) into the filelist.
4. I add
#include <ft2build.h>  
#include FT_FREETYPE_H
(I've seen this in a tutorial) to my code
5. I try to compile but it failes.

Can anybody help me with this?

Using FTGL in XCode - OneSadCookie - Oct 6, 2004 11:59 AM

not if you don't post the errors you get, we can't.

Using FTGL in XCode - rzilibowitz - Oct 29, 2004 03:28 AM

I seem to be having the same problem as Simon Schoelly above. I have built freetype 2.1.9 in xcode following the INSTALL.ANY file. I put libfreetype.a into my project. When I build everything compiles and then I get a mysterious "build failed" at the end.

I have traced the problem down to zerolink. If I turn off zerolink it builds just fine. For some reason zerolink doesn't want to work with the freetype library. Any insights would be most strongly appreciated.

The only thought I have had so far is - perhaps it's a C and C++ issue. My project is in C++ and freetype is pure C. Perhaps zerolink has trouble with this. But it shouldn't - I don't think.

Anyone who understands something about zerolink please help. It would be annoying to avoid using zerolink for no good reason. Thanks.

Using FTGL in XCode - Josh - Oct 29, 2004 01:53 PM

ZeroLink is a piece of crap and generally causes more trouble than its worth.

Using FTGL in XCode - TomorrowPlusX - Nov 1, 2004 05:05 AM

I had bad experiences with FTGL when I ran a "make install" on freetype. For me, fixing it involved running a "make uninstall" and then *manually* managing my libs and headers.

For my projects which use freetype and ftgl I have in my project's root folder two folders, lib/ and include/ in which I have symlinks to libfreetype.a and libftgl.a as well as symlinks to the folders containing their respective headers. I'm also using the Open Dynamics Engine and treat its libs and headers the same way.

In Xcode I just tell it to look for headers under include/ and libs under lib/ and I manually drag-n-drop the appropriate libs to the project and tell it not to copy them. I also had to include "-lz" to the linker flags and manually added libz.dylib to my project, since freetype apparently depends on libz.

I did this for the FTGL Xcode project -- to get it to link statically against freetype -- as well as for my own projects.

This builds an executable with no outside dependancies ( of course, none outside of what's normally expected in an OS X app ).

Also, for what it's worth, I've had no problems with zero-link when I do it this way. I think this is because there is *no* ambiguity as to what needs linking and what doesn't.