我想在我的項目中使用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)。到目前爲止,沒有任何工作,我沒有想法。