在此范围内未声明“SDL_INIT”

bag*_*tio 1 c++ sdl-2

这:

#include <iostream>
#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>

int main(int argc, char ** argv)
{
  if (SDL_INIT( SDL_INIT_EVERYTHING ) < 0 )
  {
      std::cout << " error starting SDL " <<SDL_GetError( ) << std::endl;
  }
  return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

返回:

||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
C:\Development\Projects\test\main.cpp||In function 'int main(int, char**)':|
C:\Development\Projects\test\main.cpp|7|error: 'SDL_INIT' was not declared in this scope|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Run Code Online (Sandbox Code Playgroud)

看到这个:对 SDL_Init 的未定义引用,并将我的 SDL2 版本更改为 32 位,错误仍然出现。对此很陌生,所以如果这是一个愚蠢的问题,我深表歉意。

Séb*_*ans 5

正确的语法是 SDL_Init() 而不是 SDL_INIT()。

https://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlinit.html