我正在尝试在https://tutorialsplay.com/opengl/2014/04/23/textured-cube/上练习第 1 课
当我运行名为 cube.c 的代码时,我得到了
cube.c:16:21: fatal error: SDL/SDL.h: No such file or directory
#include <SDL/SDL.h>
^
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
我已经在https://github.com/PluginIO/EX3/wiki/Setting-up-SDL2-in-Ubuntu-12.10 的指导下安装了 SDL2
不过我使用的是 14.04...
SDL2 安装成功我没有收到任何错误。
SDL.h 文件位于“/usr/local/include/SDL2”
我试图通过命令强制使用全路径链接
gcc cube.c -lglut -lGL -lGLU -l/usr/local/include/SDL2
Run Code Online (Sandbox Code Playgroud)
代替
gcc cube.c -lglut -lGL -lGLU -lSDL
Run Code Online (Sandbox Code Playgroud)
但一切都白费了……
有人知道这个链接问题的解决方案吗?
正如穆鲁指出的那样,我改成了大写,我得到了“错误:未知类型名称‘SDL_keysym’”的意思。
我发现的另一种方式是
我变了
#include <SDL/SDL.h>
Run Code Online (Sandbox Code Playgroud)
到
#include <SDL2/SDL.h>
Run Code Online (Sandbox Code Playgroud)
不再显示“致命错误:SDL/SDL.h:没有这样的文件或目录”因此现在考虑解决。但是,我收到以下错误,这些错误将在单独的线程上发布。
cube.c:105:22: error: unknown type name ‘SDL_keysym’
void handleKeyPress( SDL_keysym *keysym )
^
cube.c: In function ‘main’:
cube.c:239:5: error: unknown type name ‘SDL_VideoInfo’
const SDL_VideoInfo *videoInfo;
^
Run Code Online (Sandbox Code Playgroud)
AB:我在下面粘贴了您建议的命令的输出。
gcc cube.c `pkg-config --cflags --libs sdl`
Package sdl was not found in the pkg-config search path.
Perhaps you should add the directory containing `sdl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'sdl' found
gcc cube.c `pkg-config --cflags --libs sdl2`
cube.c:105:22: error: unknown type name ‘SDL_keysym’
void handleKeyPress( SDL_keysym *keysym )
^
cube.c: In function ‘main’:
cube.c:239:5: error: unknown type name ‘SDL_VideoInfo’
const SDL_VideoInfo *videoInfo;
^
errors continue....
Run Code Online (Sandbox Code Playgroud)
A.B*_*.B. 16
可能您已经安装了这些库,为了完整起见,我再次展示了步骤。
SDL2
sudo apt-get install libsdl2-dev
Run Code Online (Sandbox Code Playgroud)SDL1
sudo apt-get install libsdl1.2-dev
Run Code Online (Sandbox Code Playgroud)开始编译:
SDL2
gcc cube.c `pkg-config --cflags --libs sdl2`
Run Code Online (Sandbox Code Playgroud)SDL1
gcc cube.c `pkg-config --cflags --libs sdl`
Run Code Online (Sandbox Code Playgroud)示例输出:
% pkg-config --cflags --libs sdl
-D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -lSDL
% pkg-config --cflags --libs sdl2
-D_REENTRANT -I/usr/include/SDL2 -lSDL2
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
53352 次 |
| 最近记录: |