找不到SDL类型,但编译和运行函数

时间:2013-01-31 22:53:50

标签: c++ eclipse sdl

我正在使用eclipse for C ++ devs和SDL库。一些函数可以工作,但是如果我尝试声明SDL_Window它就不会编译。例如,这会编译并打开一个窗口:

/#Include <SDL/SDL.h>

    int main(int argc, char *argv[]) {
        int gogogo = 1;
        SDL_Event event;

        SDL_Init(SDL_INIT_EVERYTHING);
        SDL_WM_SetCaption("Hello World! :D", NULL);
        SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);
        while (gogogo) {
            SDL_WaitEvent(&event);
            if (event.type == SDL_QUIT)
                gogogo = 0;
        }
    SDL_Quit();
    return 0;
}

This does not:

/#include <SDL/SDL.h>
/#include <iostream>

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

  SDL_Init(SDL_INIT_VIDEO);   // Initialize SDL2

  SDL_Window *window;        // Declare a pointer to an SDL_Window

  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_SHOWN|SDL_WINDOW_OPENGL //    flags - see below
  );

  if(window==NULL){   
    std::cout << "Could not create window: " << SDL_GetError() << '\n';
    return 1;
  }

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

  SDL_DestroyWindow(window); 

  SDL_Quit(); 
  return 0;   
}

它抱怨SDL_CreateWindow和SDL_Window等无法解决。有人可以解释一下这里发生的事情吗?我之前从未真正在eclipse中设置过c ++项目。我已经遵循了几个教程,我只想让它工作。

0 个答案:

没有答案