Use zlib in juce project on Ubuntu18.04

I just try to use zlib in every my juce projects and get this error:
undefined reference to symbol ‘inflateEnd’
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
How can i fix it ? Thank you

How are you getting JUCE?

I get JUCE from download website

What exactly do you mean by this? JUCE contains a copy of the zlib code inside modules/juce_core/zip/zlib/, so there shouldn’t be any need for linking against libz.so.1 by default.

Are you changing JUCE_INCLUDE_ZLIB_CODE to “Disabled” in Projucer or to 0 in the AppConfig.h header?

I use juce with a third library and it use zlib so when i built it , i get this errors,
Then when i made new simple console project and just include zlib and use some funtions like inflate or deflate, it not change, one again i get this errors when build

when i disable JUCE_INCLUDE_ZLIB_CODE, it get diffrent error:

error: invalid conversion from ‘juce::pnglibNamespace::png_const_bytep {aka const unsigned char*}’ to ‘juce::zlibNamespace::Bytef* {aka unsigned char*}’ [-fpermissive]
png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input);

Are you using Projucer?
If yes, then please attach the generated Makefile (you might have to change its extension to .txt to be able to attach it).
If no, then please give us the command-line of the linker. I guess there is a missing -lz somewhere, but I can’t tell where exactly without knowing how the linker is currently invoked.

Here is link to Makefile.txt and log terminal when i build my project by Clion:

https://drive.google.com/open?id=13-gvdty85IslKG8OPi3hky5JXVb5_F_A

I use https://github.com/spotify/echoprint-codegen for my project with Juce.
Problem is echoprint-codegen use default zlib. And get this error when try to build.
I already add flag -lz by compiler flag scheme in juce to Codegen.cxx. But nothing change

-lz should be passed to the linker. The compiler won’t do anything with it. You can try using -Wl,lz instead to make the compiler forward the flag to the linker. Or you can try putting -lz in the “Extra Linker Flags” field of Projucer.

1 Like