Bug 691540

Summary: third party build fails
Product: MuPDF Reporter: Henry Stiles <henry.stiles>
Component: mupdfAssignee: Tor Andersson <tor.andersson>
Status: RESOLVED FIXED    
Severity: normal CC: christinedelight.top85, vincent.torri
Priority: P4    
Version: unspecified   
Hardware: Macintosh   
OS: MacOS X   
Customer: Word Size: ---

Description Henry Stiles 2010-08-09 04:46:04 UTC
cc -o build/debug/opj_bio.o -c thirdparty/openjpeg/libopenjpeg/bio.c -Ifitz -Imupdf -Wall -pipe -g -I/usr/X11R6/include -m32 -Ithirdparty/jbig2dec -Ithirdparty/openjpeg/libopenjpeg -Ithirdparty/jpeg -Ithirdparty/zlib -Ithirdparty/freetype/include  -DOPJ_STATIC
In file included from thirdparty/openjpeg/libopenjpeg/opj_includes.h:104,
                 from thirdparty/openjpeg/libopenjpeg/bio.c:32:
thirdparty/openjpeg/libopenjpeg/opj_malloc.h:84:25: error: malloc.h: No such file or directory
make: *** [build/debug/opj_bio.o] Error 1


uname -a
Darwin henry-stiles2s-macbook-pro.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

the header file malloc.h which can't be found is in /usr/include/malloc/ - note the Makefile.osx makefile distributed with openjpeg compiles the code okay.  

I temporarily patched the code a follows, after which all was well on my mac

diff -r ./libopenjpeg/opj_malloc.h ../../../thirdparty/openjpeg/libopenjpeg/opj_malloc.h
79,80c79,80
< /* #define HAVE_MEMALIGN */
< 			#include <malloc/malloc.h>		
---
> 			#define HAVE_MEMALIGN
> 			#include <malloc.h>		


but that's a hack for my machine, generally the third party zip should be integrated better with mupdf.
Comment 1 Tor Andersson 2010-08-10 15:56:17 UTC
I can't compile openjpeg out of the box even with Makefile.osx:

$ make -f Makefile.osx 
gcc -O3 -fPIC -Ilibopenjpeg -c libopenjpeg/bio.c -o libopenjpeg/bio.o
In file included from libopenjpeg/opj_includes.h:104,
                 from libopenjpeg/bio.c:32:
libopenjpeg/opj_malloc.h:80:25: error: malloc.h: No such file or directory

I've been reluctant to change the source in mupdf-thirdparty, preferring to
keep it pristine so we don't have to keep patching it when we upgrade the
packages in it.
Comment 2 vincent.torri 2010-08-11 13:23:00 UTC
(In reply to comment #1)
> I can't compile openjpeg out of the box even with Makefile.osx:
> 
> $ make -f Makefile.osx 
> gcc -O3 -fPIC -Ilibopenjpeg -c libopenjpeg/bio.c -o libopenjpeg/bio.o
> In file included from libopenjpeg/opj_includes.h:104,
>                  from libopenjpeg/bio.c:32:
> libopenjpeg/opj_malloc.h:80:25: error: malloc.h: No such file or directory

including malloc.h is usually a bad idea. It's better to include stdlib.h
Comment 3 Tor Andersson 2011-03-10 13:49:47 UTC
This problem looks like it has been fixed in openjpeg 1.4.