I'm a WRF modeler, and have a memory leak in one of the pre-processors
(metgrid.exe) that I'm trying to track down. As part of that, I'd like to use
my own (updated) compilations of various libraries, including zlib (AKA libz).
Below I've included my configure scripts for zlib, hdf5, netcdf-c, and
netcdf-fortran. I have also included several /etc/profile.d/ files that set
$LD_LIBRARY_PATH, etc.
After compilation, if I use /usr/bin/ldd to check which version of zlib an
executable is going to use, it shows the gcc one, not the one I told it to use.
# ldd hdf5-1.8.20.pgi/bin/h5copy | grep libz
libz.so.1 =>
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libz.so.1
(0x00007f62bbc77000)
# ldd netcdf-c-4.7.2.pgi/build/bin/ncgen | grep libz
libz.so.1 =>
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libz.so.1
(0x00007effdfcbf000)
# ldd wrf/WPS-4.1/metgrid.exe | grep libz
libz.so.1 =>
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libz.so.1
(0x00007f0ce30a7000)
If anyone can see my error, or give me some hints, or tell me that /usr/bin/ldd
is unreliable, I would be very appreciative.
# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
# echo $LD_LIBRARY_PATH | tr : "\n"
/opt/ohpc/pub/compiler/gcc/7.3.0/lib64
/usr/local/src/zlib-1.2.11/lib
/usr/local/src/hdf5-1.8.20.pgi/lib
/usr/local/src/libpng-1.6.37/lib
/usr/local/src/netcdf-c-4.7.2.pgi/build/lib
/usr/local/pgi/linux86-64/2019/lib
/usr/local/pgi/linux86-64/2019/libso
/usr/local/src/szip-2.1.1/lib
# cat zlib-1.2.11/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
# cat hdf5-1.8.20.pgi/my.configure
#!/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
# cat netcdf-c-4.7.2.pgi/my.configure
#!/bin/csh -f
setenv CC pgcc
setenv CXX pgc++
setenv FC pgfortran
setenv F77 pgf77
setenv F90 pgfortran
setenv FFLAGS "-tp=istanbul"
setenv CFLAGS "-fPIC -tp=istanbul"
set HDF5 = /usr/local/src/hdf5-1.8.20.pgi
set ZLIB = /usr/local/src/zlib-1.2.11
setenv LD_LIBRARY_PATH $HDF5/lib:$LD_LIBRARY_PATH
setenv CPPFLAGS "-I$ZLIB/include -I$HDF5/include"
setenv LDFLAGS "-L$HDF5/lib -lhdf5_hl -lhdf5 -lm -L$ZLIB/lib -lz -ldl"
make distclean >& /dev/null
if (-e config.cache) rm config.cache
if (-e build) rm -r build
echo $LD_LIBRARY_PATH | tr : "\n"
./configure \
--prefix=`pwd`/build \
--enable-shared \
--enable-netcdf-4 \
--enable-hdf5 \
--disable-dap \
--disable-doxygen \
>&! my.configure.out
make >&! make.out
make install >&! make.install.out
# cat netcdf-fortran-4.5.2.pgi/my.configure
#!/bin/csh -f
set NETCDF = /usr/local/src/netcdf-c-4.7.2.pgi/build
setenv FC pgfortran
setenv F77 pgf77
setenv F90 pgfortran
setenv CC pgcc
setenv CXX pgCC
setenv LD_LIBRARY_PATH $NETCDF/lib:$LD_LIBRARY_PATH
setenv LDFLAGS "-L$NETCDF/lib"
setenv CPPFLAGS "-I$NETCDF/include"
setenv FFLAGS "-tp=istanbul"
setenv CFLAGS "-tp=istanbul"
make distclean >& /dev/null
./configure \
--prefix=$NETCDF \
>&! my.configure.out
make install >&! make.install.out
# cat /etc/profile.d/hdf5.csh
setenv HDF5 /usr/local/src/hdf5-1.8.20.pgi
setenv HDF5_DIR /usr/local/src/hdf5-1.8.20.pgi
setenv HDF5_path /usr/local/src/hdf5-1.8.20.pgi
setenv HDF5_VERSION 1.8.20
if ( "${path}" !~ *${HDF5}/bin* ) then
set path = ( $path ${HDF5}/bin )
endif
if !($?LD_LIBRARY_PATH) then
setenv LD_LIBRARY_PATH $HDF5_DIR/lib
else
if ( "$LD_LIBRARY_PATH" !~ *$HDF5_DIR/lib* ) then
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$HDF5_DIR/lib
endif
endif
# cat /etc/profile.d/netcdf.csh
#
setenv NETCDF /usr/local/src/netcdf-c-4.7.2.pgi/build
setenv NETCDFHOME $NETCDF
setenv NETCDF_DIR $NETCDF
if ( "${path}" !~ *${NETCDF}/bin* ) then
set path = ( ${NETCDF}/bin $path )
endif
if !($?LD_LIBRARY_PATH) then
setenv LD_LIBRARY_PATH $NETCDF_DIR/lib
else
if ( "$LD_LIBRARY_PATH" !~ *$NETCDF_DIR/lib* ) then
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$NETCDF_DIR/lib
endif
endif
# cat /etc/profile.d/zlib.csh
#
setenv ZLIB /usr/local/src/zlib-1.2.11
if !($?LD_LIBRARY_PATH) then
setenv LD_LIBRARY_PATH $ZLIB/lib
else
if ( "$LD_LIBRARY_PATH" !~ *$ZLIB/lib* ) then
setenv LD_LIBRARY_PATH $ZLIB/lib:${LD_LIBRARY_PATH}
endif
endif
- Bart