Matthew McGoogan
Matthew McGoogan

Reputation: 6845

Errors building Freetype application with Visual Studio

I've been going bonkers the last week on this problem.

I've been trying to build against a static library for Freetype, I've tried after building the lib using the included VC2010 project and also downloading a pre-built library with no luck. I always get the same errors below. I've tried with multiple examples and the same. I'm able to successfully compile and link against the lib using gcc (after building a .a library), this problem seems to be isolated to Visual Studio..

1>f:\audio\libs\header\freetype\fterrdef.h(35): error C2143: syntax error : missing '}' before '('
1>f:\audio\libs\header\freetype\fterrdef.h(35): error C2143: syntax error : missing ';' before '<L_TYPE_raw>'
1>f:\audio\libs\header\freetype\fterrdef.h(35): error C2059: syntax error : '<L_TYPE_raw>'
1>f:\audio\libs\header\freetype\fterrors.h(164): error C2143: syntax error : missing ';' before '}'
1>f:\audio\libs\header\freetype\fterrors.h(177): error C2059: syntax error : '}'
1>f:\audio\libs\header\freetype\fterrors.h(177): error C2143: syntax error : missing ';' before '}'
1>f:\audio\libs\header\freetype\freetype.h(38): error C2143: syntax error : missing ';' before '{'
1>f:\audio\libs\header\freetype\freetype.h(38): error C2447: '{' : missing function header (old-style formal list?)

Example code that can cause this error:

#include <windows.h>
#include <ft2build.h>
#include FT_FREETYPE_H

int main(int argc, char **argv)
{
    return 0;
}

Upvotes: 2

Views: 2776

Answers (1)

kosob
kosob

Reputation: 61

I had the same issue while building FreeType2 in VS2013 with VS2013 toolset (SDK). No Google results seem to have answer to this so far so I thought I'd share even though the thread is bit old (but the problem is still recent! FreeType ver. 2.6 still suffers from the same problem).

For reference, this can be reproduced by minimal example:

#include <ft2build.h>
#include FT_FREETYPE_H

FT_Library  library;

So the problem and solution is quite simple but was unfortunately buried in output log and wasn't that obvious at first glimpse so it needed some investigation.

There is a clash with header names between FreeType2 library and Windows SDK, namely with the fttypes.h file which gets dragged in from:

C:\Program Files (x86)\Windows Kits\8.1\Include\shared\fttypes.h

Instead, VS should include FT2 header that is located in:

your_FT2_root\include\fttypes.h

This is easy to workaround - in your Project Properties (Alt+F7) rearrange header search paths so FreeType2 path is first (for me bringing FT2 at the top worked like a charm).

Hope this helps!

Cheers, Henryk

Upvotes: 3

Related Questions