我刚开始使用 SDL2(在 Ubuntu 13.04 x64 上),一切都很顺利,直到我尝试使用 SDL_image。
我添加了这段代码,用于加载图像:
SDL_Texture* LoadImage(std::string file)
{
SDL_Texture* tex = NULL;
tex = IMG_LoadTexture(ren, file.c_str());
if (tex == NULL)
throw std::runtime_error("Failed to load image: " + file + IMG_GetError());
return tex;
}
我与 -lSDL2 和 -lSDL2_image 链接,我得到了这个未定义的引用:
g++ -o "SDL" ./src/main.o -lSDL2 -lSDL2_image
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_malloc"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_memcmp"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_strncasecmp"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_memset"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_free"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_memcpy"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_sscanf"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_isspace"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_realloc"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_strcmp"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_strncmp"
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libSDL2_image.so: riferimento non definito a "SDL_snprintf"
collect2: error: ld returned 1 exit status
我究竟做错了什么??