Undefined reference to gzopen, gzeof, gzread, gzclose_r
hlischt opened this issue · 1 comments
I'm running Debian Testing x86_64. After creating a build directory, running cmake ../src -DECT_FOLDER_SUPPORT=ON
, and then running make, I get the following error:
[...]
[ 73%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o
[ 74%] Building C object zlib/CMakeFiles/zlib.dir/adler32_simd.c.o
[ 74%] Building C object zlib/CMakeFiles/zlib.dir/crc32.c.o
[ 76%] Building C object zlib/CMakeFiles/zlib.dir/crc32_simd.c.o
[ 76%] Building C object zlib/CMakeFiles/zlib.dir/deflate.c.o
[ 76%] Building C object zlib/CMakeFiles/zlib.dir/gzlib.c.o
[ 77%] Building C object zlib/CMakeFiles/zlib.dir/gzread.c.o
[ 77%] Building C object zlib/CMakeFiles/zlib.dir/inffast.c.o
[ 79%] Building C object zlib/CMakeFiles/zlib.dir/inffast_chunk.c.o
[ 79%] Building C object zlib/CMakeFiles/zlib.dir/inflate.c.o
[ 79%] Building C object zlib/CMakeFiles/zlib.dir/inftrees.c.o
[ 80%] Building C object zlib/CMakeFiles/zlib.dir/trees.c.o
[ 80%] Building C object zlib/CMakeFiles/zlib.dir/zutil.c.o
[ 82%] Linking C static library libzlib.a
[ 82%] Built target zlib
[ 82%] Building C object zopfli/CMakeFiles/zopfli.dir/blocksplitter.c.o
[ 83%] Building CXX object zopfli/CMakeFiles/zopfli.dir/deflate.cpp.o
[ 83%] Building CXX object zopfli/CMakeFiles/zopfli.dir/katajainen.cpp.o
[ 83%] Building C object zopfli/CMakeFiles/zopfli.dir/lz77.c.o
[ 85%] Building C object zopfli/CMakeFiles/zopfli.dir/squeeze.c.o
[ 85%] Building C object zopfli/CMakeFiles/zopfli.dir/util.c.o
[ 86%] Building C object zopfli/CMakeFiles/zopfli.dir/zlib_container.c.o
[ 86%] Building CXX object zopfli/CMakeFiles/zopfli.dir/zopfli_gzip.cpp.o
[ 88%] Linking CXX static library libzopfli.a
[ 88%] Built target zopfli
[ 89%] Building CXX object optipng/CMakeFiles/optipng.dir/optipng.cpp.o
[ 89%] Building CXX object optipng/CMakeFiles/optipng.dir/codec.cpp.o
[ 91%] Building C object optipng/CMakeFiles/optipng.dir/image.c.o
[ 91%] Building C object optipng/CMakeFiles/optipng.dir/opngreduc/opngreduc.c.o
[ 91%] Linking CXX static library liboptipng.a
[ 91%] Built target optipng
[ 92%] Building CXX object leanify/CMakeFiles/leanify.dir/leanify.cpp.o
[ 92%] Building CXX object leanify/CMakeFiles/leanify.dir/zip.cpp.o
[ 92%] Linking CXX static library libleanify.a
[ 92%] Built target leanify
[ 94%] Building CXX object lodepng/CMakeFiles/lodepng.dir/lodepng.cpp.o
[ 94%] Building CXX object lodepng/CMakeFiles/lodepng.dir/lodepng_util.cpp.o
[ 95%] Linking CXX static library liblodepng.a
[ 95%] Built target lodepng
[ 95%] Building CXX object CMakeFiles/ect.dir/main.cpp.o
[ 97%] Building CXX object CMakeFiles/ect.dir/gztools.cpp.o
[ 97%] Building CXX object CMakeFiles/ect.dir/jpegtran.cpp.o
[ 98%] Building C object CMakeFiles/ect.dir/LzFind.c.o
[ 98%] Building CXX object CMakeFiles/ect.dir/support.cpp.o
[100%] Building CXX object CMakeFiles/ect.dir/zopflipng.cpp.o
[100%] Building C object CMakeFiles/ect.dir/mozjpeg/transupp.c.o
[100%] Linking CXX executable ect
/usr/bin/ld: zopfli/libzopfli.a(zopfli_gzip.cpp.o): in function `ZopfliGzip(char const*, char const*, unsigned int, unsigned int, unsigned int, unsigned char)':
zopfli_gzip.cpp:(.text+0x269): undefined reference to `gzopen'
/usr/bin/ld: zopfli_gzip.cpp:(.text+0x29c): undefined reference to `gzeof'
/usr/bin/ld: zopfli_gzip.cpp:(.text+0x2bc): undefined reference to `gzread'
/usr/bin/ld: zopfli_gzip.cpp:(.text+0x354): undefined reference to `gzclose_r'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/ect.dir/build.make:203: ect] Error 1
make[1]: *** [CMakeFiles/Makefile2:295: CMakeFiles/ect.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
For reference, I was able to compile without errors on a previous commit:
git checkout -b prezip 5f654b0b9d20ae13240d8da5fa2a2ca6dcd232f2
Not sure why this happens, it works fine on macOS. It looks like the only relevant change was moving the calls to functions defined in src/zlib/gzread.c from src/gztools.cpp to src/zopfli/zopfli_gzip.cpp, so perhaps there's an issue with the cmake build in the zopfli folder having access to the zlib library. Not sure why this would be though as lodepng also uses zlib functions and it worked fine before the recent changes.