C ++链接器错误SDL图像-无法读取符号

问题描述:

我正在尝试使用SDL_Image库,并且已将.so添加到项目的链接库列表中(顺便说一下,我正在使用Code :: Blocks)。

I'm trying to use the SDL_Image library and I've added the .so to the link libraries list for my project (I'm using Code::Blocks, by the way).

这样做之后,当我去编译时,出现以下错误:

After doing this, when I go to compile, I get this error:

Linking console executable: bin/Debug/ttfx
/usr/lib32/libSDL_image-1.2.so: could not read symbols: File in wrong format

这是什么意思,我如何使它工作?

What does this mean and how can I get it working?

编辑:我正在使用gcc。

I'm using gcc.

谢谢!

在链接步骤中,存在不兼容的情况,因为某些目标文件是编译为32位,有些则为64位。查看其路径 libSDL_image.so 可能是针对32位编译的。

During the linking step there are incompatibilities since some of your object files were compiled for 32-bit and some for 64-bit. Looking at its path libSDL_image.so was probably compiled for 32-bit.

如果使用GNU编译器,请添加 -m32 到您的 CXXFLAGS ,也可以将对象编译为32位。

If you use the GNU compiler add -m32 to your CXXFLAGS to compile your objects for 32-bit, too.