SDL/SDL.h:没有这样的文件或目录

SDL/SDL.h: No such file or directory

本文关键字:SDL 文件      更新时间:2023-10-16

我正在按照教程在 Eclipse 中设置 SDL。

我必须下载 7zip 才能打开 tar 文件。 我根据教程使用 7 zip 复制所有文件。 我尝试将SDL.dll的副本放入C:WINDOWSSYSTEM32中,并将项目文件夹放在我的 eclipse 工作区中。

当我尝试运行以下代码时:

#include "SDL/SDL.h"
int main( int argc, char* args[] )
{
    //Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );
    //Quit SDL
    SDL_Quit();
    return 0;
}

我收到以下编译错误:

..main.cpp:1:21: SDL/SDL.h: No such file or directory
..main.cpp: In function `int main(int, char**)':
..main.cpp:6: error: `SDL_INIT_EVERYTHING' undeclared (first use this function)
..main.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
..main.cpp:6: error: `SDL_Init' undeclared (first use this function)
..main.cpp:9: error: `SDL_Quit' undeclared (first use this function)

我尝试将包含语句替换为以下内容:

#include <SDL/SDL.h> 

但这也没有成功。

您是否忘记执行教程中的步骤 3?

从链接的教程:

  1. 之后,打开存档中的包含子文件夹,并将名为"SDL"的文件夹解压缩到 MinGW 包含文件夹,该文件夹应位于 C:\MinGW\include。

这些编译错误是由于编译器无法找到包含在main.cpp中的 SDL 头文件造成的。

发生这种情况是因为您没有告诉编译器在哪里可以找到 SDL 标头。尝试将-I"path_to_your_SDL_include_directory"传递给编译器。