我剛開始使用SDL2(在Ubuntu 13.04 x64上),一切都很順利,直到我嘗試使用SDL_image。SDL2 - 未定義的引用 - Ubuntu
我加了這段代碼,加載圖片:
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
我在做什麼錯??
以防萬一,這是不是可以爲[ubuntu.se]一個問題? – brasofilo
我實際上不確定問題是否與Ubuntu相關,或者如果我沒有正確鏈接,或者類似的東西。 – Sylar
我也不是,這不是我的工作領域。查看他們的[幫助中心](http://askubuntu.com/help)和/或研究網站。 – brasofilo