Error compiling freeimage on Win7 x64

BlitzMax Forums/Brucey's Modules/Error compiling freeimage on Win7 x64

Russell(Posted 2011) [#1]
BMax compiles every other Brucey module (with only a few exceptions) with no trouble, but freeimage.mod gives this error:
Compiling:pngwrite.c
Compiling:pngwtran.c
Compiling:pngwutil.c
Compiling:bio.c
In file included from C:/BlitzMax/mod/bah.mod/freeimage.mod/src/LibOpenJPEG/opj_includes.h:104,
                 from C:/BlitzMax/mod/bah.mod/freeimage.mod/src/LibOpenJPEG/bio.c:32:
C:/BlitzMax/mod/bah.mod/freeimage.mod/src/LibOpenJPEG/opj_malloc.h:67:25: mm_malloc.h: No such file or directory
Build Error: failed to compile C:/BlitzMax/mod/bah.mod/freeimage.mod/src/LibOpenJPEG/bio.c
Process complete

Any ideas?

Thanks in advance!
Russell


Brucey(Posted 2011) [#2]
In src/LibOpenJPEG/opj_malloc.h

Try changing this bit at line 66 :
	#ifdef __GNUC__
		#include <mm_malloc.h>
		#define HAVE_MM_MALLOC


to this


	#ifdef __GNUC__
		#include <malloc.h>
		#define HAVE_MM_MALLOC



Russell(Posted 2011) [#3]
I will give that a try as soon as possible! :)

If it's a misspelling of the malloc.h filename, how come everyone doesn't get this error when compiling? (Or maybe they do, but are able to find the problem and fix it on their own ;^P

Russell


Russell(Posted 2011) [#4]
That did the trick, Brucey! Thanks!

Russell


Brucey(Posted 2011) [#5]
It's an issue with old(er) versions of MinGW. I believe versions which have a GCC >= 4.x do not have this problem.

I should probably change that bit to use different includes depending on the version of GCC (for minGW)


Russell(Posted 2011) [#6]
Hello, Brucey!

Sorry for the really late reply to this. I neglected to try to compile any example programs for freeimage (The module itself compiles just fine after the "malloc" change). All of the examples report one or more variations of the following:


C:/BlitzMax/mod/bah.mod/freeimage.mod/freeimage.debug.win32.x86.a(tcd.c.debug.win32.x86.o):tcd.c:(.text+0x1acc): undefined reference to `_mm_malloc'


or

C:/BlitzMax/mod/bah.mod/freeimage.mod/freeimage.debug.win32.x86.a(tcd.c.debug.win32.x86.o):tcd.c:(.text+0x507f): undefined reference to `_mm_free'



I only use GCC version 3.4.2 because that is the one contained in Mark's Module Compiling tutorial (MinGW 5.1.3). I would love to use the latest minGW, but had no end of troubles getting both modules AND example programs to compile with it. (It sure would be nice if BMax's distributable contained the latest version of minGW [or at least the parts necessary for module compilation] - I think this would solve a lot of issues people are having with module compilation).

Anyway, the file referenced in the above error line, tcd.c, contained no reference to '_mm_malloc' or '_mm_free' (nor the HAVE_MM_MALLOC constant/compiler directive), so I have no idea what to fix.

Any ideas?

Russell


Brucey(Posted 2011) [#7]
Some of the modules do require a more modern GCC now - the march of progress, etc.

Maybe I need two complete installations of BlitzMax set up for old and new GCCs, but it's a bit of a pain to swap environment settings about.

I think someone uses a script to copy files into the BlitzMax structure. I suppose that would be useful at least for an easier way of ensuring the required files are in the right place.