[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #OFO-584294]: CPPFLAGS and LDFLAGS don't seem to work with --disable-shared



Hi Kris,

> I'm having a difficult time trying to get NetCDF4/HDF5 compiled for a
> static-only environment.  I have Googled around, and understand the
> CPPFLAGS and LDFLAGS must be pointing to the HDF libs/headers.  Here is
> what I do to reproduce the fatal error:
> 
> # uname -a
> Linux mast 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012
> x86_64 x86_64 x86_64 GNU/Linux  [Linux Mint Version 13]
> 
> zlib-1.2.8 # make distclean
> zlib-1.2.8 # ./configure --prefix=/Volumes/L2A/G2S/Dev --static
> zlib-1.2.8 # make install
> 
> hdf5-1.8.11 # make distclean
> hdf5-1.8.11 # ./configure --prefix=/Volumes/L2A/G2S/Dev --enable-fortran
> --with-zlib-dir=/Volumes/L2A/G2S/Dev --disable-shared --enable-static-exec
> hdf5-1.8.11 # make install

It's not necessary to --enable-fortran when building hdf5, because the netCDF
C library (and the netCDF Fortran library that depends on it) only use the
HDF C API.  But it shouldn't cause problems to enable the hdf5 Fortran API.
We just don't test with that combination.

> netcdf-4.1.3 # make distclean
> netcdf-4.1.3 # export CPPFLAGS="-I/Volumes/L2A/G2S/Dev/include"
> netcdf-4.1.3 # export LDFLAGS="-L/Volumes/L2A/G2S/Dev/lib"
> netcdf-4.1.3 # ./configure --prefix=/Volumes/L2A/G2S/Dev
> --enable-fortran --with-udunits --enable-netcdf4 --with-libcf
> --disable-shared

We also don't test with the combination of the older netCDF-4.1.3 (released
in June 2011, more than 2 years ago) with hdf5-1.8.11 (released in May 2013),
though it should work OK.  The most recent netCDF releases are 4.3.0 for the
netCDF C library and 4.2 for the Fortran library.  (They have been independent
releases since C netCDF 4.2.0, so their version numbers don't match.)

> configure: error: Can't find or link to the hdf5 library. Use
> --disable-netcdf-4, or see config.log for errors.
> 
> Here is the part of the config.log file just before the error:
> 
> ***************************************************
> configure:26943: gcc -o conftest -fPIC -I/Volumes/L2A/G2S/Dev/include
> -L/Volumes/L2A/G2S/Dev/lib conftest.c -lhdf5  -lm -lz -lgcc >&5
> /Volumes/L2A/G2S/Dev/lib/libhdf5.a(H5PL.o): In function
> `H5PL_term_interface':
> H5PL.c:(.text+0x9d): undefined reference to `dlclose'
> /Volumes/L2A/G2S/Dev/lib/libhdf5.a(H5PL.o): In function `H5PL_load':

Try adding 

  export LIBS=-ldl

before the netCDF configure and build.  I think this is needed when using 
HDF5-1.8.11 and static builds, because that version supports dynamically 
loadable filters.  If that succeeds for you, we'll add it to our installation 
documentation.

--Russ

> H5PL.c:(.text+0x2c3): undefined reference to `dlsym'
> H5PL.c:(.text+0x3b3): undefined reference to `dlopen'
> H5PL.c:(.text+0x3ce): undefined reference to `dlsym'
> H5PL.c:(.text+0x504): undefined reference to `dlclose'
> H5PL.c:(.text+0x581): undefined reference to `dlerror'
> H5PL.c:(.text+0x7d0): undefined reference to `dlclose'
> collect2: ld returned 1 exit status
> configure:26943: $? = 1
> configure: failed program was:
> | /* confdefs.h */
> ...CLIPPED PREPROCESSOR CODE HERE...
> configure:26960: result: no
> configure:26967: error: Can't find or link to the hdf5 library. Use
> --disable-netcdf-4, or see config.log for errors.
> 
> **************************************************
> 
> Seems to have failed on compiling conftest.c or missing confdefs.h.
> Where are these files located?  They seems to be missing from the
> netcdf/hdf5/zlib directory trees.

The conftest.* files are transient files generated by the configure
script in the process of deriving properties of the development
environment.  They can be found in the config.log file that the
configure script writes, with each line of the source code prefixed 
by "| ", and that whole block of code preceded by the compile command,
so you can just cut that block of code out and delete the first 2 chars
of each line to get the conftest.c source.  Usually the last such 
block of code in config.log is the one that failed, and the detailed
error message is also right before the block of code.  The confdefs.h
header files are similarly in config.log and can be extracted the same
way.

There are hundreds of tests run by configure, so it needs to create 
hundreds of these little test files and header files and then overwrite
them with the next test, but all the gory details are in config.log.

--Russ

> 
> This is the content of the master lib directory that LDFLAGS points to:
> 
> # ls -al /Volumes/L2A/G2S/Dev/lib/
> total 6808
> drwxr-xr-x 3 walker walker    4096 Jul  1 21:59 .
> drwxr-xr-x 8 walker walker    4096 Jul  1 20:25 ..
> -rw-r--r-- 1 root   root   6018222 Jul  1 21:56 libhdf5.a
> -rw-r--r-- 1 root   root    427246 Jul  1 21:58 libhdf5_fortran.a
> -rwxr-xr-x 1 root   root       986 Jul  1 21:58 libhdf5_fortran.la
> -rw-r--r-- 1 root   root    212838 Jul  1 21:58 libhdf5_hl.a
> -rw-r--r-- 1 root   root    121816 Jul  1 21:59 libhdf5hl_fortran.a
> -rwxr-xr-x 1 root   root      1075 Jul  1 21:59 libhdf5hl_fortran.la
> -rwxr-xr-x 1 root   root       971 Jul  1 21:58 libhdf5_hl.la
> -rwxr-xr-x 1 root   root       926 Jul  1 21:56 libhdf5.la
> -rw-r--r-- 1 root   root      3359 Jul  1 21:56 libhdf5.settings
> -rw-r--r-- 1 root   root    148790 Jul  1 21:53 libz.a
> drwxr-xr-x 2 root   root      4096 Jul  1 21:53 pkgconfig
> 
> 
> And the include directory pointed to by CPPFLAGS:
> 
> # ls -al /Volumes/L2A/G2S/Dev/include
> total 13096
> drwxr-xr-x 2 walker walker    4096 Jul  1 21:59 .
> drwxr-xr-x 8 walker walker    4096 Jul  1 20:25 ..
> -rw-r--r-- 1 root   root     22588 Jul  1 21:56 H5ACpublic.h
> -rw-r--r-- 1 root   root    155712 Jul  1 21:58 h5a.mod
> -rw-r--r-- 1 root   root     14401 Jul  1 21:56 H5api_adpt.h
> -rw-r--r-- 1 root   root    205645 Jul  1 21:58 h5a_provisional.mod
> -rw-r--r-- 1 root   root      5629 Jul  1 21:56 H5Apublic.h
> -rw-r--r-- 1 root   root      1918 Jul  1 21:56 H5Cpublic.h
> -rw-r--r-- 1 root   root    194766 Jul  1 21:58 h5_dble_interface.mod
> -rw-r--r-- 1 root   root    152417 Jul  1 21:58 h5d.mod
> -rw-r--r-- 1 root   root      1592 Jul  1 21:58 H5DOpublic.h
> -rw-r--r-- 1 root   root    238788 Jul  1 21:58 h5d_provisional.mod
> -rw-r--r-- 1 root   root      6616 Jul  1 21:56 H5Dpublic.h
> -rw-r--r-- 1 root   root   1818902 Jul  1 21:59 h5ds.mod
> -rw-r--r-- 1 root   root      2748 Jul  1 21:58 H5DSpublic.h
> -rw-r--r-- 1 root   root    133472 Jul  1 21:58 h5e.mod
> -rw-r--r-- 1 root   root    131225 Jul  1 21:58 h5e_provisional.mod
> -rw-r--r-- 1 root   root     19492 Jul  1 21:56 H5Epubgen.h
> -rw-r--r-- 1 root   root      9174 Jul  1 21:56 H5Epublic.h
> -rw-r--r-- 1 root   root      1874 Jul  1 21:58 H5f90i_gen.h
> -rw-r--r-- 1 root   root      1587 Jul  1 21:58 H5f90i.h
> -rw-r--r-- 1 root   root      1705 Jul  1 21:56 H5FDcore.h
> -rw-r--r-- 1 root   root      2172 Jul  1 21:56 H5FDdirect.h
> -rw-r--r-- 1 root   root      1723 Jul  1 21:56 H5FDfamily.h
> -rw-r--r-- 1 root   root      3243 Jul  1 21:56 H5FDlog.h
> -rw-r--r-- 1 root   root      2806 Jul  1 21:56 H5FDmpi.h
> -rw-r--r-- 1 root   root      2499 Jul  1 21:56 H5FDmpio.h
> -rw-r--r-- 1 root   root      1900 Jul  1 21:56 H5FDmpiposix.h
> -rw-r--r-- 1 root   root      2095 Jul  1 21:56 H5FDmulti.h
> -rw-r--r-- 1 root   root     13879 Jul  1 21:56 H5FDpublic.h
> -rw-r--r-- 1 root   root      1555 Jul  1 21:56 H5FDsec2.h
> -rw-r--r-- 1 root   root      1561 Jul  1 21:56 H5FDstdio.h
> -rw-r--r-- 1 root   root    141742 Jul  1 21:58 h5f.mod
> -rw-r--r-- 1 root   root      5034 Jul  1 21:58 h5fortran_types.mod
> -rw-r--r-- 1 root   root    130738 Jul  1 21:58 h5f_provisional.mod
> -rw-r--r-- 1 root   root      8717 Jul  1 21:56 H5Fpublic.h
> -rw-r--r-- 1 root   root    130533 Jul  1 21:58 h5global.mod
> -rw-r--r-- 1 root   root    148040 Jul  1 21:58 h5g.mod
> -rw-r--r-- 1 root   root      7309 Jul  1 21:56 H5Gpublic.h
> -rw-r--r-- 1 root   root   1823182 Jul  1 21:59 h5im.mod
> -rw-r--r-- 1 root   root    135253 Jul  1 21:58 h5i.mod
> -rw-r--r-- 1 root   root      3432 Jul  1 21:58 H5IMpublic.h
> -rw-r--r-- 1 root   root      4641 Jul  1 21:56 H5Ipublic.h
> -rw-r--r-- 1 root   root    134370 Jul  1 21:58 h5lib.mod
> -rw-r--r-- 1 root   root       481 Jul  1 21:58 h5lib_provisional.mod
> -rw-r--r-- 1 root   root    145644 Jul  1 21:58 h5l.mod
> -rw-r--r-- 1 root   root       472 Jul  1 21:58 h5l_provisional.mod
> -rw-r--r-- 1 root   root      9324 Jul  1 21:56 H5Lpublic.h
> -rw-r--r-- 1 root   root   1981432 Jul  1 21:59 h5lt.mod
> -rw-r--r-- 1 root   root     14340 Jul  1 21:58 H5LTpublic.h
> -rw-r--r-- 1 root   root      1933 Jul  1 21:56 H5MMpublic.h
> -rw-r--r-- 1 root   root    141912 Jul  1 21:58 h5o.mod
> -rw-r--r-- 1 root   root       472 Jul  1 21:58 h5o_provisional.mod
> -rw-r--r-- 1 root   root     10238 Jul  1 21:56 H5Opublic.h
> -rw-r--r-- 1 root   root     99992 Jul  1 21:56 H5overflow.h
> -rw-r--r-- 1 root   root      2882 Jul  1 21:56 H5PLextern.h
> -rw-r--r-- 1 root   root    218097 Jul  1 21:58 h5p.mod
> -rw-r--r-- 1 root   root    146733 Jul  1 21:58 h5p_provisional.mod
> -rw-r--r-- 1 root   root     24235 Jul  1 21:56 H5Ppublic.h
> -rw-r--r-- 1 root   root      4011 Jul  1 21:58 H5PTpublic.h
> -rw-r--r-- 1 root   root     22121 Jul  1 21:56 H5pubconf.h
> -rw-r--r-- 1 root   root     11180 Jul  1 21:56 H5public.h
> -rw-r--r-- 1 root   root    131526 Jul  1 21:58 h5r.mod
> -rw-r--r-- 1 root   root    136944 Jul  1 21:58 h5r_provisional.mod
> -rw-r--r-- 1 root   root      3686 Jul  1 21:56 H5Rpublic.h
> -rw-r--r-- 1 root   root    152208 Jul  1 21:58 h5s.mod
> -rw-r--r-- 1 root   root      7405 Jul  1 21:56 H5Spublic.h
> -rw-r--r-- 1 root   root   1847554 Jul  1 21:59 h5tb.mod
> -rw-r--r-- 1 root   root      8577 Jul  1 21:58 H5TBpublic.h
> -rw-r--r-- 1 root   root    172628 Jul  1 21:58 h5t.mod
> -rw-r--r-- 1 root   root       472 Jul  1 21:58 h5t_provisional.mod
> -rw-r--r-- 1 root   root     27329 Jul  1 21:56 H5Tpublic.h
> -rw-r--r-- 1 root   root     12558 Jul  1 21:56 H5version.h
> -rw-r--r-- 1 root   root    132426 Jul  1 21:58 h5z.mod
> -rw-r--r-- 1 root   root     11262 Jul  1 21:56 H5Zpublic.h
> -rw-r--r-- 1 root   root      2655 Jul  1 21:56 hdf5.h
> -rw-r--r-- 1 root   root      1604 Jul  1 21:58 hdf5_hl.h
> -rw-r--r-- 1 root   root   1811836 Jul  1 21:58 hdf5.mod
> -rw-r--r-- 1 root   root     15472 Jul  1 21:53 zconf.h
> -rw-r--r-- 1 root   root     87883 Jul  1 21:53 zlib.h
> 
> What am I doing wrong in my effort to only get static libs?  I can
> compile fine if I choose dynamic building instead.
> 
> Thanks,
> Kris
> --
> Kristoffer T. Walker
> Assoc. Research Geophysicist
> Scripps Institution of Oceanography
> 9500 Gilman Drive, MC 0225
> La Jolla, CA 92093-0225
> http://sail.ucsd.edu/~walker
> +1-650-534-0126 (work)
> +1-650-814-4452 (cell)
> 
> 
Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: OFO-584294
Department: Support netCDF
Priority: Normal
Status: Closed