Reputation: 567
I'm having trouble using the Freetype library in my Xcode project and have the include at the top of my code #include <ft2build.h>
; however when I build the code, I get the error 'Ft2build.h' No Such file or directory. I had linked the library 'libfreetype.dylib' and included the following in 'Other Link Flags' in the Build tab: '-l/usr/local/include/freetype2/'.
I'm quite new to Xcode, and would appreciate any help here from someone that could highlight what I've missed.
Many thanks, Alex
Upvotes: 5
Views: 2226
Reputation: 3126
To link with freetype2 on macOS in XCode, determine the header/lib paths by running the following two commands in the terminal:
freetype-config --cflags // example output: -I/opt/X11/include/freetype2
freetype-config --libs // example output: -L/opt/X11/lib -lfreetype
... and change the Xcode project-setting accordingly:
"Header Search Paths" => /opt/X11/include/freetype2
"Library Search Paths" => /opt/X11/lib
"Other Linker Flags" => -lfreetype
Upvotes: 3
Reputation: 122401
The issue is that you are putting (the necessary) -I/usr/local/include/freetype2
flags in Other Linker Flags and the linker doesn't care about include files.
Instead modify the Header Search Path in the Build Settings.
You will probably also need to modify the Library Search Path as well, in order to pickup the library.
Avoid using Other Linker Flags if you can help it.
Upvotes: 4