
나는 에서 Lesson_1을 연습하려고 합니다. https://tutorialsplay.com/opengl/2014/04/23/textured-cube/
나는 Cube.c라는 코드를 실행했을 때 다음과 같은 결과를 얻었습니다.
cube.c:16:21: fatal error: SDL/SDL.h: No such file or directory
#include <SDL/SDL.h>
^
compilation terminated.
다음 지침에 따라 SDL2를 설치했습니다. https://github.com/PluginIO/EX3/wiki/Setting-up-SDL2-in-Ubuntu-12.10
14.04를 사용하고 있지만..
SDL2 설치가 성공적으로 완료되었으며 오류가 발생하지 않았습니다.
SDL.h 파일은 "/usr/local/include/SDL2"에 있습니다.
명령으로 강제로 전체 경로 연결을 사용하려고 했습니다.
gcc cube.c -lglut -lGL -lGLU -l/usr/local/include/SDL2
대신에
gcc cube.c -lglut -lGL -lGLU -lSDL
하지만 모두 헛수고였습니다...
이 연결 문제에 대한 해결책을 아는 사람이 있습니까?
muru가 지적한 대로 대문자로 변경했는데 "오류: 알 수 없는 유형 이름 'SDL_keysym'"이라는 의미가 작동했습니다.
내가 발견한 다른 방법은
나는 변했다
#include <SDL/SDL.h>
에게
#include <SDL2/SDL.h>
더 이상 "치명적인 오류: 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;
^
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....
답변1
아마도 이미 라이브러리를 설치했을 것입니다. 완전성을 이유로 단계를 다시 표시합니다.
SDL2
sudo apt-get install libsdl2-dev
SDL1
sudo apt-get install libsdl1.2-dev
다음을 사용하여 컴파일을 시작하세요.
SDL2
gcc cube.c `pkg-config --cflags --libs sdl2`
SDL1
gcc cube.c `pkg-config --cflags --libs sdl`
샘플 출력:
% 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