Using alternative zlib

Hi All,

I'm trying to use the JUCE_INCLUDE_ZLIB_CODE define to use a different Zlib library. Unfortunately, I can't seem to make this work, even with a new project (created from 3.1.1) as a test. Here is what I did:

- Create new GUI application

- Set flag to disable including the JUCE zlib code

- Included source code and headers to project from latest zlib build

- Set JUCE_ZLIB_INCLUDE_PATH to find new zlib.h 

Tried to compile but get the following error:

JuceLibraryCode/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp:129:33: Unknown type name 'z_uInt'; did you mean 'uInt'?

- Set #define Z_PREFIX in zconf.h to avoid the error

I then get the error from zconf.h:

/Libraries/zlib/zconf.h:380:12: Unknown type name 'z_Byte'; did you mean 'Byte'?

I thought this might have something to do with the 'hack' mentioned by Jules in the zconf.h included with Juce.

- So I added #undef __MACTYPES__ to zconf.h

- I then start getting a ton of errors in the libpng libraries. 

/JuceLibraryCode/modules/juce_graphics/image_formats/pnglib/pngwutil.c:521:32: Assigning to 'z_Bytef *' (aka 'unsigned char *') from incompatible type 'png_const_bytep' (aka 'const unsigned char *')

Just wondering if you have any hints of what could be causing this. I'm pretty close to giving up and rather fixing the issue on my real project which is having conflict with another library which is including zlib (which also uses the Z_PREFIX define, which is I guess why its not so easy to isolate).


Can I ask why you're trying to do this?

The way I use it inside juce, I've wrapped it in an internal namespace, so it shouldn't cause any name conflicts if you try to link your app with another copy of zlib - is that what's happening?

Sorry Jules,

Realized the issue. I'm trying to include the opennurbs library, which allows writing to the .3dm file format used by Rhino3d. I hit the same naming conflict that you patched against in your implementation of zlib... the Byte typedef in OSX's MacTypes.h.

The fix was achieved by doing exactly what you did in the included zconf.h that ships with JUCE:

#undef __MACTYPES__

Now that I made that change in the zconf.h that is included with opennurbs, the lib compiles nicely alongside of JUCE. I was attacking the problem in all of the wrong ways.