Static linking freetype and FTGL
I recently started to use FTGL to display nice truetype for a HUD for my game.
FTGL itself works great. It looks good, performance is excellent, no problem.
The trouble is getting Xcode to statically link against the libs, so that the app is self-contained, and doesn't require users to install freetype!
I doscovered recently that Xcode was dynamically linking against libfreetype.dylib even though I had provided it with libfreetype.a
So, to fix this, my process was this: I built freetype on the command line but didn't install it -- so no headers or libs in /usr/local; and then rebuilt FTGL using the Xcode project, linking against the libfreetype.a in the freetype build folder.
libftgl built and linked, fine.
So then I built my app using it, and got this linker error:
Any ideas? What can I do?
FTGL itself works great. It looks good, performance is excellent, no problem.
The trouble is getting Xcode to statically link against the libs, so that the app is self-contained, and doesn't require users to install freetype!
I doscovered recently that Xcode was dynamically linking against libfreetype.dylib even though I had provided it with libfreetype.a
So, to fix this, my process was this: I built freetype on the command line but didn't install it -- so no headers or libs in /usr/local; and then rebuilt FTGL using the Xcode project, linking against the libfreetype.a in the freetype build folder.
libftgl built and linked, fine.
So then I built my app using it, and got this linker error:
Code:
ld: lib//libfreetype.a(ftgzip.o) illegal reference to symbol: _inflateEnd defined in indirectly referenced dynamic library /usr/lib/libz.1.dylib
Any ideas? What can I do?
You could just include the dylib with the application bundle, afaik.
Your error is a link error, you should probably link with libz.dylib though.
Your error is a link error, you should probably link with libz.dylib though.
It seems peculiar to me, though, since libz.dylib exists in the standard Mac OS X install, in /usr/local.
What also seems odd is that when I was dynamically linking against libfreetype.dylib, I didn't get this linker error.
What also seems odd is that when I was dynamically linking against libfreetype.dylib, I didn't get this linker error.
I'm not sure how you do this in XCode, but you should be able to fix this problem by adding -lz to the linking line.
I would personally include a static build of libz as well since it's a really small library. Though I think every version of X has it.
I would personally include a static build of libz as well since it's a really small library. Though I think every version of X has it.
every version of Mac OS X has libz. Just add /usr/lib/libz.dylib to your project and all will be fine.
dylibs can link to libraries themselves, which is why you didn't get it before. "static libraries" are really just collections of object files, so you have to link to their dependencies yourself.
dylibs can link to libraries themselves, which is why you didn't get it before. "static libraries" are really just collections of object files, so you have to link to their dependencies yourself.
Well, I already had /usr/lib/libz.dylib in my test project, but adding -lz did it! And a quick look at the output of otool tells me I'm set -- no dependencies outside of standard OS X libs and frameworks.
Thanks!
Thanks!
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
How do I flip upside down fonts in FTGL | mr5z | 4 | 5,849 |
Mar 3, 2014 03:36 PM Last Post: JustinFic |
|
Xcode and FTGL | hiddenspring81 | 7 | 13,074 |
Oct 10, 2013 03:00 PM Last Post: ardowz |
|
Anyone run into this problem with FTGL? | wadesworld | 1 | 4,586 |
Apr 21, 2009 02:19 PM Last Post: Oddity007 |
|
FTGL crash when exiting program | Malarkey | 8 | 9,602 |
Mar 27, 2008 03:33 PM Last Post: Malarkey |
|
More Freetype/FTGL trouble | Fenris | 33 | 28,001 |
Sep 15, 2006 06:27 AM Last Post: TomorrowPlusX |