我实际上无法在我的笔记本电脑上使用 SDL 2.0,所以我再次重新发布整个帖子。希望其他人可以帮助我,因为我有点绝望。
“显然,我没有正确安装 SDL,因为我在 SDL 2.0 的一些教程中找到的示例程序没有正确构建。
请注意,我使用 Ubuntu 12.04 作为我的操作系统,使用 SDL 2.0.3 源代码中的说明将其安装在我的操作系统上,我使用 CodeLite 5.4,并且我使用 C 作为我的编程语言。
这是我尝试测试的代码:
#include <SDL2/SDL.h>
#include <stdio.h>
int main(int argn,char **argv)
{
if(SDL_Init(SDL_INIT_VIDEO) != 0)
{
fprintf(stderr,"Could not initialize SDL: %s\n", SDL_GetError());
}
printf("SDL Initialized\n");
SDL_Quit();
printf("SDL Shutdown\n");
return 0;
}
但是,我明白了:
/bin/sh -c 'make -j 1 -e -f Makefile'
----------Building project:[ SDL - Debug ]----------
make[1]: Entering directory `/home/user/Documents/Programming/C/SDL'
gcc -o ./Debug/SDL @"SDL.txt" -L.
./Debug/main.o: In function `main':
/home/user/Documents/Programming/C/SDL/main.c:6: undefined reference to `SDL_Init'
/home/user/Documents/Programming/C/SDL/main.c:8: undefined reference to `SDL_GetError'
/home/user/Documents/Programming/C/SDL/main.c:13: undefined reference to `SDL_Quit'
collect2: ld returned 1 exit status
make[1]: *** [Debug/SDL] Error 1
make[1]: Leaving directory `/home/user/Documents/Programming/C/SDL'
make: *** [All] Error 2
3 errors, 0 warnings
有人可以向我解释问题是什么以及如何解决吗?”