Linking the Freetype 2 library to LM3S application

LM3S2776, Eclipse, Codesourcery GCC, arm-none-eabi-gdb

Hi All, I think I am having Linker problems and I have not yet become One with the Voodoo magic of complex makefiles.

Due to memory size constraints I am trying to use the FreeType 2 library in my application instead of storing bitmaps for large characters to be displayed on an LCD.

I have been building my application on the LM3S1968 uart_echo example (because it was a good place to start) so I am still using the Makefile (modified to suit) and as a result depend on the Makedefs file.

I have compiled Freetype 2 library with its makefile to produce libfreetype.a

Added the following to the Makefile:

IPATH+=/FreeType/include

${COMPILER}/uart_echo.axf: c:/Freetype/objs/libfreetype.a

I am following the FreeType 2 tutorial http://freetype.sourceforge.net/freetyp … step1.html

and so code looks like this:


#include “ft2build.h”

#include FT_FREETYPE_H //this is actually legal BTW

void main(){

FT_Library library; /* handle to library */ //This works fine

FT_Face face; /* handle to face object */

error = FT_Init_FreeType( &library ); //This is causing the errors


and I get the following errors

make all

LD gcc/uart_echo.axf

c:/stellarisidestuff/codesourcery/sourcery g++ lite/bin/…/lib/gcc/arm-none-eabi/4.4.1/…/…/…/…/arm-none-eabi/lib/thumb2/libc.a(lib_a-fstatr.o): In function `_fstat_r’:

fstatr.c:(.text+0x14): undefined reference to `_fstat’

c:/stellarisidestuff/codesourcery/sourcery g++ lite/bin/…/lib/gcc/arm-none-eabi/4.4.1/…/…/…/…/arm-none-eabi/lib/thumb2/libc.a(lib_a-openr.o): In function `_open_r’:

openr.c:(.text+0x16): undefined reference to `_open’

…this continues for sbrk, write, close, isatty, lseek, read

After much searching I found this thread http://old.nabble.com/Invalid-Preproces … 78956.html (where I have also posted but don’t expect a quick reply if any)

So I tried adding the lines to my Makefile (no idea if this is the solution)

freetype_cflags = freetype-config --cflags

freetype_libs = freetype-config --libs

CFLAGS += $freetype_cflags

LDFLAGS += $freetype_libs

However that generates the following errors(what is the correct format for this ??):

make all

arm-none-eabi-gcc: reetype_cflags: No such file or directory

arm-none-eabi-gcc: reetype_cflags: No such file or directory

arm-none-eabi-gcc: reetype_cflags: No such file or directory

arm-none-eabi-gcc: reetype_cflags: No such file or directory

LD gcc/uart_echo.axf

C:\StellarisIDEstuff\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-ld.EXE: reetype_libs: No such file: No such file or directory

make: *** [gcc/uart_echo.axf] Error 1

There is also this in the Codesourcery Getting Started guide. Ch 4.1 pg 20

"Sourcery G++ requires that you specify a linker script with the -T option to build applications for

bare-board targets. Linker errors like undefined reference to `read’ are a symptom of

failing to use an appropriate linker script. Default linker scripts are provided in arm-none-eabi/

lib. Refer to Chapter 5, “CS3™: The CodeSourcery Common Startup Code Sequence” for information

about the boards and linker scripts supported by Sourcery G++ Lite. You must also add the

processor options for your board, as documented in that chapter, to your compile and link command

lines."

I think there is some stupid error im making with getting this thing to link, however I have no idea !

I am not familiar with CodeSourcery but the errors indicate that fopen, fstat… etc etc, are not defined. If you are linking against newlib, this is common, you must create your own implementation of those functions, in an embedded system this is usually not done for you.

I forgot about this thread.

Problem was solved by editing the appropriate freetype library c file by commenting out those sections.

those functions are for file accesses and not used in this embedded system.

There is probably a better way to compile the library with some options to do this? I don’t know.

Either way it works now :slight_smile: