Skip to main content
GameDev.net gamedev.net
🔒 Locked

[Solved] FTGL problems

Started by tre Nov 29, 2009 at 1:30 PM 7 replies 6.5k views
Original Post
tre
tre
Hi, I have been trying to use the FTGL library to display text in my OpenGL program. Having trouble. I read a tutorial first that said something like "FTGL only needs one include" and then a #include "FTGL/ftgl.h" call. Turns out, that's not really true. Now after having a lot of problems getting it to work correctly, including it in my project, setting the project up correctly for the FreeType2 includes and the .lib file that's necessary, the code itself compiles correctly. BUT! When I try to "use" the FTGL library I get errors. First, I have included the "ftgl.h" file and then I do this:

void createFont(){
	FTGLPixmapFont font("data/xirod.ttf");
}



And there is where the program gives these errors: main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall FTPixmapFont::~FTPixmapFont(void)" (__imp_??1FTPixmapFont@@UAE@XZ) referenced in function "void __cdecl createFont(void)" (?createFont@@YAXXZ) main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FTPixmapFont::FTPixmapFont(char const *)" (__imp_??0FTPixmapFont@@QAE@PBD@Z) referenced in function "void __cdecl createFont(void)" (?createFont@@YAXXZ) I found one "solution" that told me to set the "Treat wchar_t as Built-in Type" to "No" in my project settings, but that does absolutely nothing. I hope someone here might have the answer I'm looking for. Thanks! Marcus Axelsson [Edited by - tre on November 30, 2009 7:57:00 AM]
Promethium
Promethium
"Unresolved external symbol" is a generic error that tells you that while the compiler could see the function definition (from the FTGL/ftgl.h file) the linker didn't find the actual code of the function. I'll bet FTGL comes with a *.lib file which is the compiled code of the FTGL library. Take a look in the FTGL files you downloaded.

How you make the linker recognize it is different from compiler to compiler, but in Visual Studio you can go to your project settings, choose Linker and Input, and then add the lib file to the Additional Dependencies list. You will also have to set the directory in General -> Additional Library Directories list.
tre
tre
Quote:
Original post by Promethium
"Unresolved external symbol" is a generic error that tells you that while the compiler could see the function definition (from the FTGL/ftgl.h file) the linker didn't find the actual code of the function. I'll bet FTGL comes with a *.lib file which is the compiled code of the FTGL library. Take a look in the FTGL files you downloaded.

How you make the linker recognize it is different from compiler to compiler, but in Visual Studio you can go to your project settings, choose Linker and Input, and then add the lib file to the Additional Dependencies list. You will also have to set the directory in General -> Additional Library Directories list.


I've now searched the FTGL directory for any *.lib files and found nothing. I went through manually as well, nothing. No .lib files to include.
I have included the FreeType2 "freetype.lib" if that's what you meant.
Promethium
Promethium
How did you get FTGL? A quick google turns up FTGL's SourceForge project, which seems to be source code only. In other words, you have to build it yourself to get the library file. They include Visual Studio solutions, which should make it easy enough.

Alternatively you might be able to add the FTGL source files to your own project, then you don't need the library file. However, this might be difficult if they use non-standard settings.
tre
tre
Quote:
Original post by Promethium
How did you get FTGL? A quick google turns up FTGL's SourceForge project, which seems to be source code only. In other words, you have to build it yourself to get the library file. They include Visual Studio solutions, which should make it easy enough.

Alternatively you might be able to add the FTGL source files to your own project, then you don't need the library file. However, this might be difficult if they use non-standard settings.


You're totally correct. That's why I can't get this to work.
I have to say, for being one of the "easiest" libraries, it's very poorly commented, documented and released. Seems like there's problems with newer versions of FreeType and more.
Big thanks for clearing this up for me.

I need a nice smooth way to display text (ttf with anti-aliasing) in my OpenGL project. This seemed like a quick way to go, but now I doubt that very much.

So, does anyone know of any better ways or libraries? Previously I've been using the "wgl way", from NEHE but that doesn't really fit my needs anymore.

Edit:
I've been trying to compile the FTGL library for a while now. It doesn't seem to matter how I build it, I'm just not getting a .lib file.

As you might notice, I've never done this before :)

[Edited by - tre on November 29, 2009 4:31:23 PM]
kRogue
kRogue
If you are already using SDL, you can go for SDL_ttf, at http://www.libsdl.org/projects/SDL_ttf/ having pre-made .lib's and .dll dependencies. SDL_ttf is not precisely idea at times, every time you "draw" text it creates an SDL_surface, from which you then need to update a GL texture. In all brutal honesty it is not really that nasty work to just work with freetype2 directly and create your own glyph cache as a GL-texture.

Close this Gamedev account, I have outgrown Gamedev.
tre
tre
Quote:
Original post by kRogue
If you are already using SDL, you can go for SDL_ttf, at http://www.libsdl.org/projects/SDL_ttf/ having pre-made .lib's and .dll dependencies. SDL_ttf is not precisely idea at times, every time you "draw" text it creates an SDL_surface, from which you then need to update a GL texture. In all brutal honesty it is not really that nasty work to just work with freetype2 directly and create your own glyph cache as a GL-texture.


I were looking at SDL_ttf but since I'm not using SDL it'd be too much work to rewrite my program for that.
Instead I'm doing what you suggested. Wokring with freetype2 directly. I'm using Lesson 43 from NeHe, trying hard to get it to work, though. At long last I've got text displaying in TTF but now I can't set the text color. It's constantly black.

But this subject is probably finished now. I'm not going to mess with FTGL any more, I feel that it's a bit too cumbersome.

Thanks for your replies, people!
Marcus
alexlunix
alexlunix
try to add FTGL_LIBRARY_STATIC to VS project Preprocessor Deginitions

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.