Using FTGL in XCode

Member
Posts: 156
Joined: 2002.10
Post: #1
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?

Cheers

- Iain
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #2
You need to run "make install" for FreeType, and then put the FTGL headers in your header search path.
Quote this message in a reply
Member
Posts: 156
Joined: 2002.10
Post: #3
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
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #4
AFAIK, make install just copies the headers to the default header search paths. Nothing stops you from bundling FreeType and FTGL with it.
Quote this message in a reply
Member
Posts: 156
Joined: 2002.10
Post: #5
oh yeah, sorry, I misunderstood. I will have a play with this when I go home from work.

- Iain
Quote this message in a reply
henryj
Unregistered
 
Post: #6
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.
Quote this message in a reply
Member
Posts: 144
Joined: 2004.07
Post: #7
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.
Quote this message in a reply
Simon Schoelly
Unregistered
 
Post: #8
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
Code:
#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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
not if you don't post the errors you get, we can't.
Quote this message in a reply
rzilibowitz
Unregistered
 
Post: #10
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.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #11
ZeroLink is a piece of crap and generally causes more trouble than its worth.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #12
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How do I flip upside down fonts in FTGL mr5z 4 1,528 Mar 3, 2014 03:36 PM
Last Post: JustinFic
  Xcode and FTGL hiddenspring81 7 6,717 Oct 10, 2013 03:00 PM
Last Post: ardowz
  Anyone run into this problem with FTGL? wadesworld 1 3,168 Apr 21, 2009 02:19 PM
Last Post: Oddity007
  FTGL crash when exiting program Malarkey 8 5,579 Mar 27, 2008 03:33 PM
Last Post: Malarkey
  More Freetype/FTGL trouble Fenris 33 17,896 Sep 15, 2006 06:27 AM
Last Post: TomorrowPlusX