PDA

View Full Version : [Resolved] Freetype2 Problems




Eudall
Jan 19, 2012, 04:17 PM
Hi All,

I am currently looking at doing some work using the Freetype2 API. I downloaded the latest stable release (2.4.8) from http://freetype.sourceforge.net/index2.html. After the download I untared the bzip tarball and followed the instructions within docs/INSTALL.UNIX to install:


./configure
make -s
sudo make -s install


No errors were reported on the terminal, so I assumed everything was ok and wrote a simple test application following advice from the freetype2 tutorial (http://freetype.sourceforge.net/freetype2/docs/tutorial/step1.html). The application compiles cleanly, however it fails to link. Please see output below:


Undefined symbols for architecture x86_64:
"_FT_Init_FreeType", referenced from:
_ft_init in ccK9n142.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status


I am compiling the application in the following way:

gcc -o ftTest ftTest.c -I/usr/local/include/freetype2 -I/usr/local/include


I have had a look on Google for this problem, but was unable to find anything useful. I have tried adding '-m32' to the compiler options, per a discussion on StackOverflow, but that produced the same error, but stating architecture i386.

For reference, I am using Mac OS X 10.7.2.

Any suggestions would be greatly appreciated.

Thanks



thundersteele
Jan 19, 2012, 04:28 PM
I am compiling the application in the following way:

gcc -o ftTest ftTest.c -I/usr/local/include/freetype2 -I/usr/local/include



Ok, I'm not really an expert, but when I compile C/C++ programs, my workflow is


gcc -c ftTest.c -o ftTest.o
gcc ftTest.o -LIBRARIES -o ftTest


replace -LIBRARIES with your above lib paths.

Eudall
Jan 19, 2012, 04:41 PM
Ok, I'm not really an expert, but when I compile C/C++ programs, my workflow is


gcc -c ftTest.c -o ftTest.o
gcc ftTest.o -LIBRARIES -o ftTest


replace -LIBRARIES with your above lib paths.

Hi,

Thanks for the fast response, the gcc line I am using provides the same result as yours, but you simply build objects and link these. I double checked using your suggestion, but this provides the same error.

Thanks :)

jiminaus
Jan 20, 2012, 01:05 AM
I am compiling the application in the following way:

gcc -o ftTest ftTest.c -I/usr/local/include/freetype2 -I/usr/local/include


You've specified where to find the include files, that's good and is why you can compile. But you haven't told gcc to actually link to the freetype2 library. You'll need a -L option and -l (lowercase) option to successfully link. The -L option tells gcc where to find libraries. The -l option specifies a library to actually link against.

Try this:

gcc -I/usr/local/include/freetype2 -I/usr/local/include -L/usr/local/lib -lfreetype -o ftTest ftTest.c

Eudall
Jan 20, 2012, 11:08 AM
You've specified where to find the include files, that's good and is why you can compile. But you haven't told gcc to actually link to the freetype2 library. You'll need a -L option and -l (lowercase) option to successfully link. The -L option tells gcc where to find libraries. The -l option specifies a library to actually link against.

Try this:

gcc -I/usr/local/include/freetype2 -I/usr/local/include -L/usr/local/lib -lfreetype -o ftTest ftTest.c


Damn, I knew I had forgot something. Thanks :D