Problems with SDL + freetype2 on windows

Hey all,

I’m developing a basic engine, and now I’m working on the GUI part, I want
to use freetype2 for font-rendering. I use SDL for setting up OpenGL and
handling input etc.

The SDL docs say that I have to set the code generation for my project to
’Multithreaded DLL’, so I did that.

I then linked my program against freetype206MT_D.lib, but then I get
redefined symbol messages like this one:
libcmtd.lib(dbgheap.obj) : error LNK2005: _free already defined in
MSVCRTD.lib(MSVCRTD.dll)

So I thought, lets be smart and add 2 new build configurations to the
freetype2 project: Multithreaded DLL and Debug Multithreaded DLL. Those
configurations produce freetype206DLLMT.lib and freetype206DLLMT_D.lib
respectively.

When I link against freetype206DLLMT_D.lib I only get one linking warning:
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib "msvcrt.lib"
conflicts with use of other libs; use / NODEFAULTLIB:library

When I then run my program I get a runtime error that reminds me to my DLL +
STL nightmares:
User breakpoint called from code .

According to the context it’s caused by an illegal heap pointer. Freetype
tries to free some memory using it’s internal memory-manager, which calls
free(), which calls some additional debug deallocation functions.

But the memory that causes the error is allocated by freetype2, and not by
me.

So is it a freetype2 bug? Or is it caused by my 'custom code-generation’
efforts?

Is there someone out there who had the same problem? And/or knows how to use
freetype2 together with SDL on Win32?

Or someone who just knows how to fix those linking/dependency problems? It’s
really frustrating.

Thanks,

  • Michel Stol

Is there someone out there who had the same problem? And/or knows how to use
freetype2 together with SDL on Win32?

Grab the version of Freetype2 that’s in the VisualC.zip archive in the
Windows development release of SDL_ttf:
http://www.libsdl.org/projects/SDL_ttf/

Or someone who just knows how to fix those linking/dependency problems? It’s
really frustrating.

Yeah, there’s special magic to making it work. :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment