Search code examples
c#visual-c++monogamevisual-c++-2012content-pipeline

Error: Cannot find 'freetype6.dll'


Recently I had some troubles with the MonoGame Content Pipeline tool, not loading textures. The error message said 'freeimage.dll' could not be found. I checked the MonoGame forums for a solution and ended up downloading the 64-bit version of Visual C++ Redistributable Package 2012. This fixed my problem and the Content Pipeline could load .png files once again. Now the pipeline tool is having issues loading .spritefont files. It says it is missing 'freetype.dll'. What's the deal with all these missing .dll files? I just downloaded the VC++ Redistributable Package, but it only fixed the textures, not the fonts.


Update:

I tried downloading the Visual C++ Redistributable Package 2017. However, the problem persists...


Solution

  • According to bug report 5736 in Monogame, it's a problem with them linking against the 2012 redistributable (which for a short time, wasn't available for download).

    You can try to fix it yourself by compiling freetype6 yourself, following the instructions in the bug report (below), or you can wait for them to fix the problem when bug 4485 is fixed (which appears to address the larger issue with their dependency chain), or you can see if the newer redistrib fixes it.

    ...

    Try downloading VC++ 2012 Update 4 Redistributable:
    https://www.microsoft.com/en-us/download/details.aspx?id=30679

    Or try compiling freetype6 yourself:

    mdrejhon commented on May 25, 2017 •

    Eureka! I recompiled FreeType myself and solved this problem.

    I only needed to follow a modified version of these instructions: Compiling FreeType to DLL (as opposed to static library)

    Download latest FreeType 2.8 from https://www.freetype.org/download.html
    Using VS2015 or VS2017, open freetype.sln from the builds\win32\vc2010 directory
    Modify solution to target x64 instead of x86
    Modify solution to Configuration Type of DLL instead of LIB
    Edit ftoption.h to add two lines at top
    #define FT_EXPORT(x) __declspec(dllexport) x
    #define FT_BASE(x) __declspec(dllexport) x
    Change project config to Release
    Build.
    You will see warnings, but compile succeeds.
    You will have a file "freetype28.dll" (for FreeType 2.8)
    Rename this file to "freetype6.dll" and copy to C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools
    (replacing the original freetype6.dll located there)
    

    Statically linked to 2015 or 2017 works fine.