我想在我的项目中使用SDL_image但我不能让过去此错误消息C++的libtiff:未定义参考_TIFFerrorHandler
||=== Build: Win32 Release in Sandbox (compiler: GNU GCC Compiler) ===|
..\lib\mingw32\libtiff4.a(tif_error.o):tif_error.c|| undefined reference to `_TIFFerrorHandler'|
..\lib\mingw32\libtiff4.a(tif_error.o):tif_error.c|| undefined reference to `_TIFFerrorHandler'|
..\lib\mingw32\libtiff4.a(tif_error.o):tif_error.c|| undefined reference to `_TIFFerrorHandler'|
..\lib\mingw32\libtiff4.a(tif_error.o):tif_error.c|| undefined reference to `_TIFFerrorHandler'|
||error: ld returned 1 exit status|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
起初我不确定参考_TIFFmalloc,_TIFFrealloc等,但我通过创建一个源文件并将其添加到项目中来修复它们。
tif_fix.c
// This file is intended to fix the "undefined reference..." errors
#include <stdlib.h>
#include <string.h>
#include "tiffio.h"
void* _TIFFmalloc(tmsize_t s)
{
return malloc(s);
}
void* _TIFFrealloc(void* p, tmsize_t s)
{
return realloc(p, s);
}
void _TIFFmemset(void* p, int v, tmsize_t c)
{
memset(p, v, c);
}
void _TIFFmemcpy(void* d, const void* s, tmsize_t c)
{
memcpy(d, s, c);
}
int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c)
{
return memcmp(p1, p2, c);
}
void _TIFFfree(void* p)
{
free(p);
}
所有SDL_image所需的库编译为静态库(zlib的,使用libpng,libjpeg,libwebp的libtiff4和),甚至SDL_image被编译为静态的。
我已经定义LOAD_BMP,LOAD_GIF,LOAD_JPG,LOAD_LBM,LOAD_PCX,LOAD_PNG,LOAD_PNM,LOAD_TGA,LOAD_TIF,LOAD_WEBP,LOAD_XCF,LOAD_XPM,LOAD_XV,LOAD_XXX在SDL_image项目,使图书馆。 SDL_image和库都可以毫无问题地编译。
但是,当我将SDL_image和库链接到我的应用程序的项目并尝试编译SDL_image提供的示例showimage.c时,我得到未定义的引用...错误消息。
我试图重新排序库中的代码:: Blocks的项目,因为我知道这个顺序与MinGW的重要(我用MinGW的4.8.2 X86)。到目前为止,没有任何工作,我没有想法。