I am trying to install SDL_ttf in Visual Studio Express 2012 for Windows Desktop and I have a small sample program that compiles fine, but when I run it, I get an error popup that says "The application was unable to start correctly (0xc000007b). Click OK to close the application".
I originally got basic SDL to work, then I attempted to add SDL font. I have done the following, but I'm still having trouble, if someone could hep me out, it would be much appreciated...
1) I copied all the .lib folders into the Visual Studio lib folder (C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib) (which are SDL.lib, SDLMain.lib and SDL_ttf.lib)
2) I added my include directories for SDL and SDL_ttf in the project properties (under Project >> Properties >> Configuration Properties >> VC++ Directories >> Include Directories) ... Those are ("...\SDL Main Libraries\SDL-1.2.15\include") and ("...\SDL Font Libraries\SDL_ttf-2.0.11\include")
3) I added my additional dependencies for SDL and SDL_ttf (under Project >> Properties >> Configuration Properties >> Linker >> Input >> Aditional Dependencies, where I put: SDL.lib SDLMain.lib SDL_ttf.lib inline - it looks like this: SDL.lib;SDLMain.lib;SDL_ttf.lib;%(AdditionalDependencies)
4) I have put the following dll files in the same folder as my .exe file (which is Visual Studio 2012\Projects\ConsoleApplication2\Debug), those dll files are: SDL_image.dll libfreetype-6.dll SDL_ttf.dll zlib1.dll SDL.dll
And this is my small sample program source code:
#include <iostream>
#include <SDL.h>
#include <SDL_ttf.h>
using namespace std;
int main(int argc, char** argv){
int retval = 0;
int sdlState = -1;
if((sdlState = SDL_Init(SDL_INIT_EVERYTHING)) == -1){
cerr << "SDL failed to initialize";
retval = 1;
}
SDL_Surface* screen = nullptr;
if(retval == 0){
if(nullptr == (screen =
SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_ASYNCBLIT)))
{
cerr << "Screen failed to be created";
retval = 1;
}
}
int ttfState = -1;
if(retval == 0){
if((ttfState = TTF_Init()) == -1){
cerr << "True Type Font failed to initialize";
retval = 1;
}
}
if(retval == 0){
//TTF_Font* font = TTF_OpenFont("air.ttf", 32);
SDL_Color txtColor = {0, 0, 0};
//SDL_Surface* text = TTF_RenderText_Solid(font, "Hello World",
//txtColor);
while(1){
SDL_FillRect(screen, NULL,
SDL_MapRGB(screen->format, 255, 255, 150));
//SDL_BlitSurface(text, NULL, screen, NULL);
SDL_Flip(screen);
}
}
if(ttfState != -1) TTF_Quit();
if(sdlState != -1) SDL_Quit();
return retval;
}