9 hours ago, Styves said:
Did you add the following to your code anywhere?
#define FREEIMAGE_LIB
i did.
ok, here it goes. This took me two days of trying random things and looking at the FreeImage source code. I can't believe I actually made this work. I'm actually a bit proud of myself right now. Anyway, I finally fixed this. although I'm still not sure why this fix is needed when including windows.h file. Why this wasn't an issue before including windows.h?
anyways, here it is.
So if you look at the "Utilities.h" file you will see this
//FreeImage.h
#define DLL_CALLCONV __stdcall
#define DLL_API __declspec(dllexport)
//----------------------------------------
//Utilities.h
#if defined(__cplusplus)
extern "C" {
#endif
DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeaderT(BOOL header_only, FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));
DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeader(BOOL header_only, int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));
DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeaderForBits(BYTE *ext_bits, unsigned ext_pitch, FREE_IMAGE_TYPE type, int width, int height, int bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask);
DLL_API BOOL DLL_CALLCONV FreeImage_HasRGBMasks(FIBITMAP *dib);
#if defined(__cplusplus)
}
#endif
BOOL SwapRedBlue32(FIBITMAP* dib); //This is the function that I want to use
SwapRedBlue32 is the function that I want to use in my engine. Keep in mind I'm building FreeImage as a static library and linking it to my engine.
Anyway, if you are an experienced c++ programmer (not me) you would have figured out by now why I got the linking issue only with the SwapRedBlue32 function. It's because it's not inside the extern "C" block.
so after doing the following, everything worked just fine.
//FreeImage.h
#define DLL_CALLCONV __stdcall
#define DLL_API __declspec(dllexport)
//----------------------------------------
//Utilities.h
#if defined(__cplusplus)
extern "C" {
#endif
DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeaderT(BOOL header_only, FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));
DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeader(BOOL header_only, int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));
DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeaderForBits(BYTE *ext_bits, unsigned ext_pitch, FREE_IMAGE_TYPE type, int width, int height, int bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask);
DLL_API BOOL DLL_CALLCONV FreeImage_HasRGBMasks(FIBITMAP *dib);
DLL_API BOOL DLL_CALLCONV SwapRedBlue32(FIBITMAP* dib);
#if defined(__cplusplus)
}
#endif
I still don't know why this wasn't an issue before including the Windows.h header file. You would think that this linking problem would be a problem without having to include Windows.h.
I would love someone to explain this to me. Why does including Windows.h causes this issue and why this fix worked.