Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib on mingw is misdetected #64

Open
efa opened this issue Feb 22, 2019 · 5 comments
Open

zlib on mingw is misdetected #64

efa opened this issue Feb 22, 2019 · 5 comments

Comments

@efa
Copy link

efa commented Feb 22, 2019

hi,
I got an error on ./configure using MSYS2 mingw64 shell:
user@HOST MINGW64 /d/AMBIENTE/Documents/c/jbig2enc
$ ./configure
...
checking how to hardcode library paths into programs... immediate
checking for _head_libws2_32_a in -lws2_32... no
Error! zlib not detected.

where zlib is installed, complete of all headers and dll:

user@HOST MSYS /d/AMBIENTE/Documents/c/jbig2enc
$ pacman -Sl | grep zlib
mingw32 mingw-w64-i686-zlib 1.2.11-5 [installato]
mingw64 mingw-w64-x86_64-zlib 1.2.11-5 [installato]
msys mingw-w64-cross-zlib 1.2.11-1 [installato]
msys zlib 1.2.11-1 [installato]
msys zlib-devel 1.2.11-1 [installato]

user@HOST MSYS /d/AMBIENTE/Documents/c/jbig2enc
$ pacman -Ql mingw-w64-x86_64-zlib
mingw-w64-x86_64-zlib /mingw64/
mingw-w64-x86_64-zlib /mingw64/bin/
mingw-w64-x86_64-zlib /mingw64/bin/libminizip-1.dll
mingw-w64-x86_64-zlib /mingw64/bin/zlib1.dll
mingw-w64-x86_64-zlib /mingw64/include/
mingw-w64-x86_64-zlib /mingw64/include/minizip/
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/aes.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/aes_ni.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/aesopt.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/aestab.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/brg_endian.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/brg_types.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/fileenc.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/hmac.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/prng.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/pwd2key.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/aes/sha1.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/crypt.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/ioapi.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/ioapi_buf.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/ioapi_mem.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/iowin32.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/unzip.h
mingw-w64-x86_64-zlib /mingw64/include/minizip/zip.h
mingw-w64-x86_64-zlib /mingw64/include/zconf.h
mingw-w64-x86_64-zlib /mingw64/include/zlib.h
mingw-w64-x86_64-zlib /mingw64/lib/
mingw-w64-x86_64-zlib /mingw64/lib/cmake/
mingw-w64-x86_64-zlib /mingw64/lib/cmake/minizip-exports-release.cmake
mingw-w64-x86_64-zlib /mingw64/lib/cmake/minizip-exports.cmake
mingw-w64-x86_64-zlib /mingw64/lib/libminizip.a
mingw-w64-x86_64-zlib /mingw64/lib/libminizip.dll.a
mingw-w64-x86_64-zlib /mingw64/lib/libz.a
mingw-w64-x86_64-zlib /mingw64/lib/libz.dll.a
mingw-w64-x86_64-zlib /mingw64/lib/pkgconfig/
mingw-w64-x86_64-zlib /mingw64/lib/pkgconfig/minizip.pc
mingw-w64-x86_64-zlib /mingw64/lib/pkgconfig/zlib.pc
mingw-w64-x86_64-zlib /mingw64/share/
mingw-w64-x86_64-zlib /mingw64/share/licenses/
mingw-w64-x86_64-zlib /mingw64/share/licenses/zlib/
mingw-w64-x86_64-zlib /mingw64/share/licenses/zlib/LICENSE
mingw-w64-x86_64-zlib /mingw64/share/man/
mingw-w64-x86_64-zlib /mingw64/share/man/man3/
mingw-w64-x86_64-zlib /mingw64/share/man/man3/zlib.3.gz

As 'zlib' is present in the system and 'libws2' is not needed,
a simple dirty hack like changing lines 47/48 of 'configure.ac' to:
echo "Error! zlib not detected.")
#exit -1)
let build the binary and it work.

@efa
Copy link
Author

efa commented Feb 28, 2019

attached a patch for 'configure.ac':
show WARN when winsock2 is not detected, not blame for zlib that is present and misdetected.
Generate and work on updated MSYS2.
winsock2zlib.patch.zip

@aont
Copy link

aont commented Dec 29, 2021

Thank you for the patch. I believe this is better.

configure.ac before

AC_CHECK_LIB(ws2_32, _head_libws2_32_a,,
	echo "Error! zlib not detected."
	exit -1)

configure.ac after

AC_CHECK_LIB(ws2_32, WSAStartup,,
	echo "Error! ws2_32 not detected."
	exit -1)

@efa
Copy link
Author

efa commented Dec 29, 2021

I have no tryed on a Windows system with 2021 MSYS2 and MinGW 64 bit shell, but I suspect it will never require Winsock32.
In 2019 build and binary worked without 'libws2'
Did you try if it work?

@aont
Copy link

aont commented Dec 29, 2021

I tried to build without ws2_32 by commenting out ws2_32 like this.

# AC_CHECK_LIB(ws2_32, WSAStartup,,
# 	echo "Error! zlib not detected."
# 	exit -1)
# LIBS="$LIBS -lws2_32"

It ended up in error ...

libtool: link: g++ -shared -nostdlib C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/dllcrt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/crtbegin.o  .libs/jbig2enc.o .libs/jbig2arith.o .libs/jbig2sym.o .libs/jbig2comparator.o   -lz -lwebp -lgif -ljpeg -lpng -ltiff -llept -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../.. -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/crtend.o  -g -O2   -o .libs/libjbig2enc-0.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libjbig2enc.dll.a
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/jbig2enc.o: in function `jbig2_encode_generic(Pix*, bool, int, int, bool, int*)':
C:\Users\user\Downloads\jbig2enc-0.29\src/jbig2enc.cc:899: undefined reference to `__imp_htonl'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/jbig2enc.o: in function `jbig2_pages_complete(jbig2ctx*, int*)':
C:\Users\user\Downloads\jbig2enc-0.29\src/jbig2enc.cc:688: undefined reference to `__imp_htonl'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\Downloads\jbig2enc-0.29\src/jbig2enc.cc:666: undefined reference to `__imp_htonl'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/jbig2enc.o: in function `jbig2_produce_page(jbig2ctx*, int, int, int, int*)':
C:\Users\user\Downloads\jbig2enc-0.29\src/jbig2enc.cc:743: undefined reference to `__imp_htonl'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/jbig2enc.o: in function `Segment::write(unsigned char*)':
C:\Users\user\Downloads\jbig2enc-0.29\src/jbig2segments.h:130: undefined reference to `__imp_htonl'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\Downloads\jbig2enc-0.29\src/jbig2segments.h:154: undefined reference to `__imp_htons'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:470: libjbig2enc.la] Error 1
make[1]: Leaving directory '/c/Users/user/Downloads/jbig2enc-0.29/src'
make: *** [Makefile:478: all-recursive] Error 1

ws2_32 is used for endian conversion ?

@efa
Copy link
Author

efa commented Dec 29, 2021

probably 'htonl' is in the network stack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants