Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently trying to learn how to use the FreeType2 library for drawing fonts with OpenGL. However, when I start the program it immediately crashes with the following error: "(Can't correctly start the application (0xc000007b))"

Commenting the FT_Init_FreeType removes the error and my game starts just fine. I'm wondering if it's my code or has something to do with loading the dll file.

My code:

#include "SpaceGame.h"
#include <ft2build.h>
#include FT_FREETYPE_H

//Freetype test
FT_Library library;

Game::Game(int Width, int Height)

    FT_Error error = FT_Init_FreeType(&library);
        cout << "Error occured during FT initialisation" << endl;

And my current use of the FreeType2 files. Inside my bin folder (where debug .exe is located) is: freetype6.dll, libfreetype.dll.a, libfreetype-6.dll. In Code::Blocks, I've linked to the lib and include folder of the FreeType version. And included a compiler flag: -lfreetype

My program starts perfectly fine if I comment out the FT_Init function which means the includes, and library files should be fine.

I can't find a solution to my problem and google isn't helping me so any help would be greatly appreciated.

share|improve this question
That error code (STATUS_INVALID_IMAGE_FORMAT) usually occurs when you're trying to load a 32-bit DLL into a 64-bit application, or vice versa. Are you sure both FreeType and your program were compiled for the same architecture? – Michael Madsen Jun 26 '12 at 0:38
Yeah it seemed it was indeed a .dll problem. Replaced my .dll's with dlls that were actually compiled for my current windows version which worked. I'll try to remember the error code for future problems. Thanks! – Djemon Jun 26 '12 at 11:48
up vote 0 down vote accepted

I don't see any problems with your code.

There's a few approaches I'd take to fix this problem. First, and easiest - print out the value of "error". Then figure out what that error code means. That may give you a very strong hint.

Next, assuming you're on Windows and you're still thinking it may be a dll error, grab Process Explorer. Turn it on, filter it to your application, and use that to ensure that it's finding and reading the dll. If it's not reading your dll, or it's reading some different and incompatible dll located somewhere else, then that gives you a good hint for where to focus your efforts.

After that, well, libfreetype is open-source. Grab it and start adding debug instrumentation to it. A good starting point is to look for the error code that you found in the first step and see what returns that error - that may make the problem obvious.

Finally, make a new minimal project that does nothing but initialize Freetype. If that doesn't work, it's not your code, it's the installation. If that does work, then put initialization lines in your code to figure out when the initialization stops working.

share|improve this answer
I installed Process Explorer, which is a really usefull tool for debugging! It seemed that my program wasn't loading the .dll it should load. I deleted the previous freetype dll's I was using and downloaded a freetype version compiled for windows which worked. So it was a dll problem after all. Thanks for your help, I can finally continue with my endeavours in font rendering! :) – Djemon Jun 26 '12 at 11:46

If you're looking for a quick fix, try this library: freetype-gl

But if you want to do it on your own (which I can understand, because I'm building my own font library too), try compiling Freetype from source and linking against that. That way you know it can't be because of incompatible library versions or CRT's. Bonus: you can debug inside the library.

Other than that, I can't help you much further. Freetype 2.3.5 works fine for me in Visual Studio 2008.

share|improve this answer
As far as I understand this is a good library to use for displaying fonts in OpenGL with extensive functionality. However, I'm not trying to build my own font library, just render text to screen. If I can't find a correct solution I will look into your freetype-gl, it looks quite neat and easy to implement! Thanks :D – Djemon Jun 25 '12 at 20:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.