search

Home  >  Q&A  >  body text

c++ - SDL配置问题,提示出现0XC000007b?

我按照lazy Foo的课程学习SDL开发,然后今天配置这个环境。程序能通过编译,不过运行时出现“应用程序无法正常启动(0xc000007b),请单击确定关闭应用程序),我在网上找了一下,不过给出的解决方案都不行。
问题应该是,程序是32位编译的,不过运行时的SDL2.dll是64位版本的。不过怎么解决呢?我是按照32位配置的,不过我把32位版本的SDL2.dll放在windows/System32文件夹下面时根本就没用。
用64位的SDL2.dll虽然能通过,不过却出现无法正确运行。
这是原教程的网址:http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/msvsnet2010u/ind...
作者给的示例代码:

/*This source code copyrighted by Lazy Foo' Productions (2004-2015)
and may not be redistributed without written permission.*/

//Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>

//Screen dimension constants
const int SCREEN_WIDTH = 1366;
const int SCREEN_HEIGHT = 768;

int main(int argc, char* args[])
{
    //The window we'll be rendering to
    SDL_Window* window = NULL;

    //The surface contained by the window
    SDL_Surface* screenSurface = NULL;

    //Initialize SDL
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
    }
    else
    {
        //Create window
        window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
        if (window == NULL)
        {
            printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
        }
        else
        {
            //Get window surface
            screenSurface = SDL_GetWindowSurface(window);

            //Fill the surface white
            SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

            //Update the surface
            SDL_UpdateWindowSurface(window);

            //Wait two seconds
            SDL_Delay(2000);
        }
    }

    //Destroy window
    SDL_DestroyWindow(window);

    //Quit SDL subsystems
    SDL_Quit();

    return 0;

PHP中文网PHP中文网2767 days ago630

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-17 11:58:11

    For 32bit development, you must use 32bit for the entire set. Both library and dll are.
    In addition, it is not recommended to put sdl2.dll under the system32 folder, as it may cause contamination. Just put it directly in the project.

    reply
    0
  • Cancelreply