我最近搬到了linux,我遇到了使用gcc编译SDL C程序的问题.
我正在使用的命令:
gcc `sdl-config --cflags --libs` -o main main.c
即使分离sdl-config标志:
gcc `sdl-config --cflags` -c main.c
gcc `sdl-config --libs` -o main main.o
我得到了同样的错误:
/tmp/ccHYyjKd.o: In function `main':
main.c:(.text+0xe): undefined reference to `SDL_SetMainReady'
main.c:(.text+0x18): undefined reference to `SDL_Init'
main.c:(.text+0x31): undefined reference to `SDL_SetVideoMode'
main.c:(.text+0x54): undefined reference to `SDL_MapRGB'
main.c:(.text+0x6b): undefined reference to `SDL_FillRect'
main.c:(.text+0x77): undefined reference to `SDL_Flip'
main.c:(.text+0x83): undefined reference to `SDL_WaitEvent'
main.c:(.text+0x90): undefined reference to

在尝试用GCC在Linux上编译包含SDL库的C程序时,遇到编译错误,提示对SDL函数的未定义引用。通过调整`gcc`命令的参数顺序和学习使用`GNU make`及编写`Makefile`,可以解决此问题。推荐在编译过程中始终添加`-Wall -g`选项,以帮助调试。
最低0.47元/天 解锁文章
3079

被折叠的 条评论
为什么被折叠?



