我正在尝试使用C++,SDL和SDL-image来制作游戏;我使用Code :: Blocks作为我的IDE,并且遇到了一些麻烦。Code :: Blocks SDL2.0“未定义引用'IMG_Load'”
我已经下载了最新的mingw SDL开发文件和最新的mingw SDL图像开发文件。
我把所有的SDL-image东西放到与SDL东西相同的目录中(合并到另一个中)。
我已将x86_64-w64-mingw32/include和x86_64-w64-mingw32/lib目录添加到我的Code :: Blocks搜索目录中。
我的连接设置如下:
-lmingw32
-lSDL2main
-lSDL2
-lSDL2_image
-lopengl32
-lglu32
(很显然,我用openGL为好,但我不认为这是这里参与)。
我有正确的#includes据我可以告诉:
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_opengl.h>
但我仍然得到错误:未定义的引用“IMG_Load”
这里的生成日志:
obj\Release\gfx_Texture.o:gfx_Texture.cpp:(.text+0xd7): undefined reference to `IMG_Load'
obj\Release\gfx_Texture.o:gfx_Texture.cpp:(.text+0x1dd): undefined reference to `SDL_FreeSurface'
obj\Release\gfx_Texture.o:gfx_Texture.cpp:(.text+0x1f4): undefined reference to `SDL_FreeSurface'
g:/program files(x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: obj\Release\gfx_Texture.o: bad reloc address 0x4 in section `.text.startup'
g:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
和实际代码:
SDL_Surface* image = IMG_Load(file);
其中文件是char *。
据我所知,已经出现了一些变化SDL_Surfaces在SDL 2.0工作相比,SDL 1.2(我想迁移,无论是从1.2到2.0,并从MVSC到C :: B),因此可能的方式有什么关系呢?我使用IMG_Load是否错误?
我们非常感谢您的帮助,如果能澄清任何问题,我会根据要求提供任何缺失的信息。
还有一个想法:最新版本的SDL是2.0.1,但最新版本的SDL_image是2.0.0。我需要这些版本以匹配吗?