eclipse c ++ SDL_Image库无效

时间:2014-09-07 03:52:10

标签: c++ eclipse sdl-2

这是我的代码。

#ifndef LOADBMP_H_
#define LOADBMP_H_

#include "SDL2/SDL.h"
#include "res_path.h"
#include "SDL2/SDL_image.h"
SDL_Texture* loadTexture(const std::string &file, SDL_Renderer *ren) 
{
    SDL_Texture *texture = IMG_LoadTexture(ren, file.c_str()); <-- troublesome line
    if (texture == NULL)
    {
        logSDLError(std::cout, "LoadTexture");
    }
    return texture;
}

#endif /* LOADBMP_H_ */

当我尝试编译时,它给了我一个错误:未定义的引用`IMG_LoadTexture&#39; 我已正确安装了库。我做错了什么?

1 个答案:

答案 0 :(得分:0)

如果您已正确安装它,看起来您没有正确链接它。您需要以与SDL2和SDL2_main相同的方式链接库。

例如,在下图中,您将向其添加SDL2_image(这是Windows,但同样适用于Eclipse上的其他平台)

enter image description here