Linuxbrew / legacy-linuxbrew

:skull: This repository is defunct, because it has been split into https://github.com/Linuxbrew/brew and https://github.com/Linuxbrew/homebrew-core
http://linuxbrew.sh
Other
2.23k stars 296 forks source link

libxml2: Depends on zlib #932

Closed DoomHammer closed 8 years ago

DoomHammer commented 8 years ago

If there is no system-wide zlib installed brewing libxml2 fails with (more in a gist):

./.libs/libxml2.so: undefined reference to `deflate'
./.libs/libxml2.so: undefined reference to `inflateInit2_'
./.libs/libxml2.so: undefined reference to `inflate'
./.libs/libxml2.so: undefined reference to `gzwrite'
./.libs/libxml2.so: undefined reference to `crc32'
./.libs/libxml2.so: undefined reference to `deflateEnd'
./.libs/libxml2.so: undefined reference to `gzdopen'
./.libs/libxml2.so: undefined reference to `deflateInit2_'
./.libs/libxml2.so: undefined reference to `gzread'
collect2: error: ld returned 1 exit status
make[2]: *** [testSchemas] Error 1
make[2]: Leaving directory `/tmp/libxml220160314-31332-1dwr173/libxml2-2.9.3'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/libxml220160314-31332-1dwr173/libxml2-2.9.3'
make: *** [all] Error 2

The root-casue seems to be that -lz is never specified (running make V=1):

libtool: link: /usr/bin/gcc-4.8 -D_REENTRANT -Os -w -pipe -march=core2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -Wl,--dynamic-linker=/home/linuxbrew/.linuxbrew/lib/ld.so -Wl,-rpath -Wl,/home/linuxbrew/.linuxbrew/lib -o .libs/xmllint xmllint.o  -L/home/linuxbrew/.linuxbrew/lib ./.libs/libxml2.so -ldl -lm -Wl,-rpath -Wl,/home/linuxbrew/.linuxbrew/Cellar/libxml2/2.9.3/lib

libxml2's configure script provides --with-zlib option. Should this be added just to Linuxbrew or perhaps to Homebrew as a --with-brewed-zlib option (and made default perhaps on Linux)?

sjackman commented 8 years ago

Does adding a zlib dependency resolve this issue?

depends_on "zlib" unless OS.mac?
DoomHammer commented 8 years ago

Nope, it won't get found this way as configure script doesn't have -L$(brew --prefix)/lib.

sjackman commented 8 years ago

-L$(brew --prefix)/lib is already in the LDFLAGS and LIBRARY_PATH environment variable. See

$ brew --env |egrep 'FLAGS|LIBRARY'
export CFLAGS="-Os -w -pipe -march=core2"
export CXXFLAGS="-Os -w -pipe -march=core2"
export CPPFLAGS="-isystem/home/sjackman/.linuxbrew/include"
export LDFLAGS="-L/home/sjackman/.linuxbrew/lib -Wl,--dynamic-linker=/home/sjackman/.linuxbrew/lib/ld.so -Wl,-rpath,/home/sjackman/.linuxbrew/lib"
export LIBRARY_PATH="/home/sjackman/.linuxbrew/lib"
DoomHammer commented 8 years ago

Does not reproduce on linuxbrew/linuxbrew. Must have been some quantum mechanics.

sjackman commented 8 years ago

My guess is that it was fixed by faf5144.