我想在Windows桌面的Visual Studio Express 2012中安装SDL_ttf,并且我有一个编译好的小示例程序,但是当我运行它时,出现错误弹出窗口显示“应用程序无法正确启动(0xc000007b)。单击确定关闭应用程序”。试图在Visual Studio Express 2012中安装SDL_ttf for Windows Desktop
我最初得到基本的SDL工作,然后我试图添加SDL字体。我做了以下,但我仍然遇到麻烦,如果有人可以帮我出去,这将是非常感激...
1)我将所有.lib文件夹复制到Visual Studio库文件夹(C :\ Program Files(x86)\ Microsoft Visual Studio 11.0 \ VC \ lib)(它们是SDL.lib,SDLMain.lib和SDL_ttf.lib)
2)我在项目中添加了SDL和SDL_ttf的include目录属性(在项目>>属性>>配置属性>> VC++目录>>包含目录下) ... 这些是(“... \ SDL主库\ SDL-1.2.15 \ include”) 和(“ ... \ SDL Font Libraries \ SDL_ttf-2.0.11 \ include“)
3)我添加了SDL和SDL_ttf的其他依赖关系(在Project >> Properties >> Configuration Properties >> Linker >> Input >> Aditional Dependencies中,我放入: SDL.lib SDLMain.lib SDL_ttf.lib 在线 - 它看起来像这样:SDL.lib; SDLMain.lib; SDL_ttf.lib;%(AdditionalDependencies)
4)我已经把下面的dll文件在同一文件夹作为我的.exe文件(这是视觉工作室2012 \项目\ ConsoleApplication2 \调试),这些DLL文件: SDL_image.dll libfreetype建立-6.dll SDL_ttf.dll zlib1.dll SDL.dll
这是我的小样本程序的源代码:
#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;
}
我终于得到它的工作!我玩弄了各种dll和lib文件夹 - 我终于找到了它的工作原理(我可能会使用一些64位的lib或dll文件 - 我应该有一个32位的lib或dll文件文件 - 但我不确定。 – user1296259