我实际上还没有能够在我的笔记本电脑上使用 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
有人可以向我解释一下问题是什么以及如何解决它吗?”
最佳答案
来自代码: 右键单击事件项目图标(在 TreeView 中)-> 设置 -> 通用设置 -> 链接器 -> 库
并添加:
SDL2
(无需添加 -l,或者 .a/.so codelite 会为您解决此问题)
按 F7,它应该可以正常链接
埃兰
关于c - SDL 2.0 构建错误(重复),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23377641/