问题描述
我正在使用SDL2在C中进行编程,但出现此错误:
`main': main.c:(.text+0x2d0): undefined reference to 'IMG_Load'`
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <stdio.h>
作为参考,我正在使用Arch Linux,并通过以下命令使用GCC进行编译:
gcc main.c `sdl2-config --libs -lSDL2 -lSDL2_image` -o game
解决方法
此:
gcc main.c `sdl2-config --libs -lSDL2 -lSDL2_image` -o game
应为:
gcc main.c `sdl2-config --libs` -lSDL2 -lSDL2_image -o game
换句话说,只有sdl2-config --libs
是子命令。