Fix build error with Freetype in Visual Studio
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

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

  • Microsoft Visual Studio Community 2013
  • Freetype 2.5.5
  • Windows 8.1
  • Building as C++ application

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;
}

I would like someone to complete the following for me:

  • Reproduce these errors
  • Provide a solution on how they resolved the errors and then built the application successfully
awarded to kerncy

Crowdsource coding tasks.

1 Solution

Winning solution

Hi,

I have successfully compiled your sample code with VS 2013 under Windows 8.1 and freetype 2.5.5.

Here is what I have done.

Step 1 : download and extract freetype 2.5.5, then go to folder and open

freetype > build > windows > vc2010 > freetype.sln

On first load, the project is asked to be converted to VS 2013 format, say yes. Then on the toolbar on the top, I selected "Release" for "Win32" and compilation succeeds (output files are generated in objs folder)

Step 2 : Create a new empty project (templates > Visual C++ > General > Empty project). I created a main.cpp pasting your demo code.

Step 3 : Now the hard part begin, you will have to configure your include and library path. Right click on your project and select "properties".

You will now be able to configure your include path and library path

Then start your compilation, and it succeeded for me.

Here is my projects with an "externalLibrary" folder containing freetype and the "myProject" folder containing the "FreetypeBountify" folder with the demo application. In order to success compile, you may need to update the path of your include and library path as my project are on E: drive.

Do not hesitate if you have any question, or if you want to share your projet in order to see what is wrong.

Kerncy

It works! I'm still not sure what properties I must have screwed up in my projects, I'll have to go back and compare. Thanks!
mlmcgoogan over 6 years ago