Using my own zlib with hdf5-1.8.20

I’m trying to compile hdf5-1.8.20 on CentOS 7.4 using the PGI v19.10-0 (non-LLVM) compilers. Here’s my configure script:

[code]# cat my.configure
make distclean >& /dev/null

setenv FC pgfortran
setenv CC pgcc

setenv FFLAGS “-tp=istanbul”
setenv FCFLAGS “-tp=istanbul”
setenv CFLAGS “-tp=istanbul”

./configure
–prefix=pwd
–enable-fortran
–with-zlib=/usr/local/zlib-1.2.11
>&! my.configure.out

make >&! make.out
make install >&! make.install.out[/code]

And here’s the tail of my.configure.out:

[code]Compiling Options:

           Compilation Mode: production
                 C Compiler: /usr/local/pgi/linux86-64/2019/bin/pgcc ( pgcc 19.10-0 64-bit target on x86-64 Linux -tp istanbul-64 )
                     CFLAGS: -tp=istanbul
                  H5_CFLAGS:   -c99 -Minform=inform -fast -s
                  AM_CFLAGS: 
                   CPPFLAGS: 
                H5_CPPFLAGS: -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L   -DNDEBUG -UH5_DEBUG_API
                AM_CPPFLAGS:  -I/usr/local/zlib-1.2.11/include
           Shared C Library: yes
           Static C Library: yes

Statically Linked Executables: no
LDFLAGS:
H5_LDFLAGS:
AM_LDFLAGS: -L/usr/local/zlib-1.2.11/lib
Extra libraries: -lz -ldl -lm
Archiver: ar
Ranlib: ranlib
Debugged Packages:
API Tracing: no[/code]

Looks right so far. But when I compile and check using ldd, I see it’s using the CentOS version of libz:

# ldd bin/h5copy linux-vdso.so.1 => (0x00007ffc7f391000) libhdf5.so.10 => /usr/local/src/hdf5-1.8.20.pgi/lib/libhdf5.so.10 (0x00007f31f8bb9000) [b]libz.so.1 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libz.so.1 (0x00007f31f89a1000)[/b] libdl.so.2 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libdl.so.2 (0x00007f31f8799000) libm.so.6 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libm.so.6 (0x00007f31f8491000) libpgmp.so => /usr/local/pgi/linux86-64-nollvm/19.10/lib/libpgmp.so (0x00007f31f8209000) libnuma.so.1 => /usr/local/pgi/linux86-64-nollvm/19.10/lib/libnuma.so.1 (0x00007f31f7ff9000) libpthread.so.0 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libpthread.so.0 (0x00007f31f7dd9000) libpgmath.so => /usr/local/pgi/linux86-64-nollvm/19.10/lib/libpgmath.so (0x00007f31f79c1000) libpgc.so => /usr/local/pgi/linux86-64-nollvm/19.10/lib/libpgc.so (0x00007f31f7769000) libc.so.6 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libc.so.6 (0x00007f31f7399000) libgcc_s.so.1 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libgcc_s.so.1 (0x00007f31f7181000) /lib64/ld-linux-x86-64.so.2 (0x00005622afc7d000)

What am I doing wrong?

Here’s how I compiled zlib-1.2.11:

[code]# cat my.configure
#!/bin/csh -f

make distclean >& /dev/null

setenv FC pgfortran
setenv CC pgcc

setenv FFLAGS “-tp=istanbul”
setenv CFLAGS “-tp=istanbul”

./configure
–prefix=pwd
–libdir=pwd/lib
>&! my.configure.out

make >&! make.out
make install >&! make.install.out[/code]

It looks like it worked:

[code]# ls /usr/local/src/zlib-1.2.11/lib
total 388K
-rw-r–r--. 1 bbrashers 233K Jan 9 15:27 libz.a
lrwxrwxrwx. 1 bbrashers 14 Jan 9 15:27 libz.so -> libz.so.1.2.11*
lrwxrwxrwx. 1 bbrashers 14 Jan 9 15:27 libz.so.1 -> libz.so.1.2.11*
-rwxr-xr-x. 1 bbrashers 152K Jan 9 15:27 libz.so.1.2.11*
drwxrwxr-x. 2 bbrashers 28 Jan 9 16:27 pkgconfig/

ls /usr/local/src/zlib-1.2.11/include/

total 112K
-rw-r–r--. 1 bbrashers 16K Jan 9 15:27 zconf.h
-rw-r–r--. 1 bbrashers 94K Jan 9 15:27 zlib.h[/code]

Any help would be greatly appreciated.

Bart

Hi Bart,

Before you run configure, please set LD_LIBRARY_PATH environment variable to point to the zlib library you built.

Elena

Thanks for the response. I added this last line to my compile script, following your suggestion:

setenv ZLIB /usr/local/src/zlib-1.2.11

setenv CPPFLAGS “-I$ZLIB/include”

setenv LDFLAGS “-L$ZLIB/lib”

setenv LD_LIBRARY_PATH $ZLIB/lib:$LD_LIBRARY_PATH

No help:

$ ldd bin/h5copy | grep libz

libz.so.1 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/…/…/…/…/lib64/libz.so.1 (0x00007f66bca79000)

It’s still using the one provided by the distro:

$rpm -qf /usr/lib64/libz.so.1

zlib-1.2.7-18.el7.x86_64

  • Bart

I’ve adjusted my.configure slightly, here’s the new one:

[code]#!/bin/csh -f

compile hdf5-1.8.20

make distclean >& /dev/null

setenv FC pgfortran
setenv CC pgcc

setenv FFLAGS “-tp=istanbul”
setenv FCFLAGS “-tp=istanbul”
setenv CFLAGS “-tp=istanbul”

setenv ZLIB /usr/local/src/zlib-1.2.11

setenv CPPFLAGS “-I$ZLIB/include”
setenv LDFLAGS “-L$ZLIB/lib”
setenv LD_LIBRARY_PATH $ZLIB/lib:$LD_LIBRARY_PATH

echo $LD_LIBRARY_PATH | tr : “\n”

./configure
–prefix=pwd
–enable-fortran
–with-zlib=/usr/local/zlib-1.2.11
>&! my.configure.out

sed -i “s|-L/usr/local/src/zlib-1.2.11/lib|-L/usr/local/src/zlib-1.2.11/lib -lz|g” Makefile
sed -i “s|-lz -ldl -lm|-ldl -lm|g” Makefile

make >&! make.out
make install >&! make.install.out[/code]

I can see the -Lpath followed by -lz in the Makefile:

# grep -- -lz Makefile FCLIBS = -L/usr/local/src/zlib-1.2.11/lib -lz -L/usr/local/pgi/linux86-64-nollvm/19.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -lpgf90rtl -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgftnrtl -lpgmp -lnuma -lpthread -lpgmath -lnspgc -lpgc -lrt -lm LDFLAGS = -L/usr/local/src/zlib-1.2.11/lib -lz

And yet the problem remains:

ldd bin/h5dump | grep libz

    libz.so.1 => /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libz.so.1 (0x00007fdd8db97000)

I wanted it to use my compiled version of libz.

Any ideas?