【发布时间】:2014-02-09 22:22:59
【问题描述】:
我正在尝试使用 c++、SDL 和 SDL-image 来制作游戏;我正在使用 Code::Blocks 作为我的 IDE,但遇到了一些麻烦。
我已经下载了最新的 mingw SDL 开发文件,以及最新的 mingw SDL-image 开发文件。
我已将所有 SDL 图像内容与 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);
file 是 char*。
我了解与 SDL 1.2 相比,SDL_Surfaces 在 SDL 2.0 中的工作方式发生了一些变化(我正在尝试从 1.2 迁移到 2.0 以及从 MVSC 迁移到 C::B),那也可以有关系吗?我是不是用错了 IMG_Load?
非常感谢您的帮助,如果可以澄清任何问题,我会应要求提供任何缺失的信息。
再想一想:SDL 的最新版本是 2.0.1,而 SDL_image 的最新版本是 2.0.0。我需要这些版本来匹配吗?
【问题讨论】:
标签: c++ codeblocks sdl-2 sdl-image