致命错误:sdl.h:没有这样的文件或目录

时间:2015-06-30 13:03:08

标签: c sdl

我遇到一些问题需要编译CHIP-8解释器。 按下ctrl + f9进行编译后,我收到一条消息,说“Build以错误结束。继续?”。

检查构建日志会显示以下错误:C:/ Workspace / **** / **** / main.c:4:17:致命错误:sdl.h:没有这样的文件或目录

我尝试将SDL.h复制到源目录中,但是没有用。

我尝试在源代码中创建一个名为“SDL”(src / SDL / SDL.h)的目录,但是没有用。

我还尝试在src(SDL / SDL.h)旁边创建一个文件夹。这也不起作用。

之后我尝试了#include< .SDL.h>,#include< .sdl.h>,#include< .SDL.dll>和#include< .sdl.dll> (忽略“<”符号后面的句号)

我也尝试过复制SDL版本1.2.15和SDL版本2.0.3的文件。这确实有效。

我做了一些根本错误的事吗? 如何编译?

2 个答案:

答案 0 :(得分:1)

你必须说你的编译器sdl.h所在的位置,-I/path/to/sdl启用gcc或填充msvc中的Include Path

(不要移动它,因为它(sdl.h)可能需要其他头文件)

答案 1 :(得分:1)

Here's a step-by-step on how to get SDL1.2.5 working with codelite:

  1. Download the "Development Libraries" from here
  2. Extract the tar.gz file contents to a directory. For eg: C:\mysdl
  3. In codelite, right-click over the project's name in the "Workspace View"
  4. From the context menu, select "Settings..."
  5. The 'Project Settings' dialog will appear.
  6. In the "configuration Type" choose "Debug" or "Release", based on your requirements. You can also, do the following steps for both Debug and Release.
    • Go to "Compiler" tab
      • In "Additional Search Path", add the path where all the sdl include files are. For eg: C:\mysdl\include
    • Go to "Linker" tab
      • In "Library Path", add you lib path eg: C:\mysdl\lib\
      • In the "Options" append -lSDL -lSDLmain -lmingw32 -mwindows(case-matters)
  7. Copy C:\mysdl\bin\SDL.dll to C:\WINDOWS\SYSTEM32 or if 64-bit C:\Windows\SysWOW64
  8. When including headers you must use #include "SDL\SDL.h" or #include "SDL.h" depending on how you configure your directory structure.