使用visual studio 2013的sdl 2(简单的例子没有工作继续崩溃)

时间:2015-01-23 22:11:06

标签: c++ visual-studio-2013 sdl-2

我正在使用Visual Studio 2010编译SDL2而没有任何麻烦。我决定将visual studio升级到2013.我的简单示例没有运行并继续向我显示此消息

enter image description here

这就是我所做的

我的项目文件夹看起来像

main.cpp 
SDL2.dll ( from F:xxx\SDL2-2.0.3\lib\x86

CMD

 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC> cl /?
    Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x86
    Copyright (C) Microsoft Corporation.  All rights reserved.

从cmd编译

cl /EHsc /MD  main.cpp /Fetest.exe /I F:\C++_Libraries\SDL2\SDL2-2.0.3\include /link /LIBPATH:F:\C++_Libraries\SDL2\SDL2-2.0.3\lib\x86 SDL2.lib SDL2main.lib /SUBSYSTEM:CONSOLE

的main.cpp

#include <cstdio>
#include "SDL.h"

int main(int argc, char* argv[]) {

    SDL_Window *window;                    // Declare a pointer

    SDL_Init(SDL_INIT_VIDEO);              // Initialize SDL2

    // Create an application window with the following settings:
    window = SDL_CreateWindow(
        "An SDL2 window",                  // window title
        SDL_WINDOWPOS_UNDEFINED,           // initial x position
        SDL_WINDOWPOS_UNDEFINED,           // initial y position
        640,                               // width, in pixels
        480,                               // height, in pixels
        SDL_WINDOW_OPENGL                  // flags - see below
    );

    // Check that the window was successfully made
    if (window == NULL) {
        // In the event that the window could not be made...
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }

    // The window is open: enter program loop (see SDL_PollEvent)

    SDL_Delay(3000);  // Pause execution for 3000 milliseconds, for example

    // Close and destroy the window
    SDL_DestroyWindow(window);

    // Clean up
    SDL_Quit();
    return 0;
}

1 个答案:

答案 0 :(得分:1)

这可能是因为您可能没有使用2013工具集重新编译您的dll。