I'm trying to use SDL_image in my project however I can't get past this error message
||=== 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)) ===|
At first I got undefined reference to _TIFFmalloc, _TIFFrealloc etc. but I fixed them by creating a source file and adding it to the project.
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);
}
All the libraries needed by SDL_image are compiled as static libraries (zlib, libpng, libjpeg, libwebp and libtiff4) and even SDL_image is compiled as static.
I have defined 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 in the SDL_image project to enable the libraries. Both SDL_image and the libraries compile without any problems.
However, when I link SDL_image and the libraries to my application's project and try to compile the example showimage.c provided with SDL_image I get the undefined reference to... error message.
I've tried to reorder the libraries in the Code::Blocks project because I know the order is important with MinGW (I'm using MinGW 4.8.2 x86). So far nothing works and I'm out of ideas.