Advertisement

Can't compile Lesson43

Started by June 18, 2004 02:24 AM
4 comments, last by Arthenor 20 years, 5 months ago
I downloaded the lesson43 and i get these errors when trying to compile the lesson. I added all the required libraries and did all the linking Lesson43.obj : error LNK2001: unresolved external symbol "public: void __thiscall freetype::font_data::init(char const *,unsigned int)" (?init@font_data@freetype@@QAEXPBDI@Z) Lesson43.obj : error LNK2001: unresolved external symbol "void __cdecl freetype::print(struct freetype::font_data const &,float,float,char const *,...)" (?print@freetype@@YAXABUfont_data@1@MMPBDZZ) Lesson43.obj : error LNK2001: unresolved external symbol "public: void __thiscall freetype::font_data::clean(void)" (?clean@font_data@freetype@@QAEXXZ)
What compiler are you using?
Advertisement
Either you're missing a library or the freetype headers you have don't match the library version you have (either due to editing, version mismatch or just a buggy release). Try downloading a fresh copy of the freetype library and headers and recompile.

Enigma
Try adding the freetype.cpp file to your project, this file contains the function definentions of the functions the linker gives errors of.

EDIT: the 'unresolved external symbol' error means the linker can't find a declaration of a function which is commonly because of a library that's not linked or a source file that is not compiled.
adding the freetype.cpp in the project solved the problem for me, but i'm getting another error "FT_Init_FreeType
failed" its from this section of the code


void font_data::init(const char * fname, unsigned int h) {
//Allocate some memory to store the texture ids.
textures = new GLuint[128];

this->h=h;

//Create and initilize a freetype font library.
FT_Library library;
if (FT_Init_FreeType( &library ))
throw std::runtime_error("FT_Init_FreeType failed");

//The object in which Freetype holds information on a given
//font is called a "face".
FT_Face face;

//This is where we load in the font information from the file.
//Of all the places where the code might die, this is the most likely,
//as FT_New_Face will die if the font file does not exist or is somehow broken.
if (FT_New_Face( library, fname, 0, &face ))
throw std::runtime_error("FT_New_Face failed (there is probably a problem with your font file)");

//For some twisted reason, Freetype measures font size
//in terms of 1/64ths of pixels. Thus, to make a font
//h pixels high, we need to request a size of h*64.
//(h << 6 is just a prettier way of writting h*64)
FT_Set_Char_Size( face, h << 6, h << 6, 96, 96);

//Here we ask opengl to allocate resources for
//all the textures and displays lists which we
//are about to create.
list_base=glGenLists(128);
glGenTextures( 128, textures );

//This is where we actually create each of the fonts display lists.
for(unsigned char i=0;i<128;i++)
make_dlist(face,i,list_base,textures);

//We don't need the face information now that the display
//lists have been created, so we free the assosiated resources.
FT_Done_Face(face);

//Ditto for the library.
FT_Done_FreeType(library);
}
I'm getting the same error, and I believe it comes from this section of code:

if (FT_Init_FreeType( &library ))
throw std::runtime_error("FT_Init_FreeType failed");

Indicating that for some reason, FT_Init_FreeType isn't working. What could cause this error and how can it be fixed?

This topic is closed to new replies.

Advertisement