[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] Need help to compile application
From: |
Werner LEMBERG |
Subject: |
Re: [ft] Need help to compile application |
Date: |
Tue, 10 May 2011 06:09:13 +0200 (CEST) |
> As I am a new user of Freetype 2 library I am facing difficulty in
> compiling the application code. I have moved the application code
> given below in a file example.c. I have been able to successfully
> install the freetype 2 on my Linux machine. What should be my
> command to compile the application example.c using gcc or make on a
> linux console? Please help.
To the compiler, you must give a path to the FreeType include files at
compile time using `-I', and to the linker, you must give a path to
the FreeType library at link time (`-L'), together with the name of
the library itself (`-l'). Since gcc is normally used for both in a
simple compilation, you can do this in one step. `-o' gives the name
of the final binary.
Let's assume that you've installed in /usr/local, then the include
files are in /usr/local/include/freetype2, and the library is in
/usr/local/lib.
gcc -o example \
-I/usr/local/include/freetype2 \
-L/usr/local/lib \
example.c \
-lfreetype
Howewer, depending on your installation, you must add other libraries
also on which FreeType depends. The `absolutely correct way' is to
use the `freetype-config' script to get the compiler and linker flags.
For example, on my GNU/Linux box the calls
freetype-config --libs
freetype-config --cflags
respectively return
-L/usr/local/lib -lfreetype -lz -lbz2
-I/usr/local/include/freetype2 -I/usr/local/include
Note that there is a problem in your program:
> #include <freetype/freetype.h>
> #include <freetype/ftglyph.h>
As demonstrated in the tutorial sample files, you are (a) missing the
central entry macro, ft2build.h, and (b) you should use symbolic
names:
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
I have had only a quick look, but the rest of your code looks OK.
Werner