freetype2 linking problems

Started by
2 comments, last by NSDuo 11 years, 1 month ago

I'm trying to get started with Freetype2 in my Xcode 4 project (on Mac OS X of course). I successfully compiled the library through the command line, and I got two dylibs and a static library. I figured I just add one of them to my project and I'll have access to the files right?

Obviously because I'm posting this, it didn't work.


#include<ft2build.h> // FILE NOT FOUND

The tutorials specified doing it like this.


#include<libfreetype/ft2build.h> // FILE STILL NOT FOUND

Nope.


#include<libfreetype.a/ft2build.h>
#include<libfreetype.dylib/ft2build.h> // HOW DID I THINK THIS WOULD WORK?

I was desperate with this attempt...

I also tried working with the header/library/framework search paths, but couldn't get Xcode to find the files

So...

Is there an additional step I didn't know about when adding a non-framework library to a project?

Could something have gone wrong when I made the libraries?

Should I be including them differently for Mac OS?

Did I not provide enough information about my problem? (I always do somehow...)

Macbook Pro 2.66Ghz dual core, 4GB ram, 512MB vram, MacOSX 9.1, Windows 8.1
Xcode 5.0.2, C++, lua

Advertisement
Libraries usually have header files, source code and a way to build (compile them). Header files usually are in directory named /include.

When you are compiling your project, it happens in two steps: compiling each .cpp into separate binary file and linking these binary blobs into single executable.

Header files describe (forward declare) stuff that is available in .cpp and that binary blob.

To compile .cpp file, you need all header files it uses (ft2build.h).

To link all binary blobs together, you need that compiled library (libfreetype.a) - it is a binary blob.

You have to add freetype's /include directory to your project's "include path list". When done, you can use "#include <ft2build.h>" to compile your files.

You have to add compiled "libfreetype.a" to your project's "link libraries" list. It will be linked into final executable.

It didn't work...

I added the static library and set the header search path to "usr/local": didn't work.

I changed the path to "usr/local/lib": didn't work.

I changed the path to "usr/local/include": I think it worked once, but when I added the next include it stopped working, and it won't work even when I set it back.

Is there a way to see where the compiler is actually looking?

Macbook Pro 2.66Ghz dual core, 4GB ram, 512MB vram, MacOSX 9.1, Windows 8.1
Xcode 5.0.2, C++, lua

FIXED!!!

What I should have remembered is that my framework has a companion app to help test its functions. And it was the application failing to build when my framework was having no problems. Apparently I needed to:

1: Add the static library to my framework.

2: Add "usr/local/include" and "usr/local/include/freetype2" as the framework's header search paths.

3: Then add "usr/local/include" and "usr/local/include/freetype2" as the companion application's header search paths.

EDIT: NOW FIXED

I spoke too soon. Once I started using the library, I got errors saying: "_BZ2_bzdecompress" not found, "_BZ2_bzdecompressEnd" not found, and "_inflate" not found. This was fixed by downloading the "bzip" and "zlib" libraries and including them in my project.

Macbook Pro 2.66Ghz dual core, 4GB ram, 512MB vram, MacOSX 9.1, Windows 8.1
Xcode 5.0.2, C++, lua

This topic is closed to new replies.

Advertisement