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

Re: HDF-netCDF conflicts (fwd)



>To: address@hidden
>From: "Kurt Stockinger" <address@hidden>
>Subject: Re: 20040401:HDF-netCDF conflicts
>Organization: LBL
>Keywords: 200403312247.i2VMlQA6008230

Relating to above message, answer from HDF HelpDesk ...

------- Forwarded Message

Date:    Fri, 02 Apr 2004 10:43:51 -0600
From:    HDF User Support <address@hidden>
To:      Kurt Stockinger <address@hidden>, address@hidden
Subject: Re: HDF-netCDF conflicts

Hi Kurt and Russ,

To use the SD interface, you must include the "mfhdf" library.
However, the SD interface in HDF uses the same netCDF names internally as
does netCDF, which causes a conflict if you want to build HDF and netCDF
together.
  
We came up with an option that would allow users (C only) to 
build HDF with NetCDF by renaming the netcdf calls used by HDF.

Here is an excerpt from the (old) HDF INSTALL file:

      2.4.3.2 Using HDF/MFHDF libraries w/ original netCDF library
      ************************************************************
      To use the HDF/MFHDF libraries(libdf.a, libmfhdf.a) with the
      original netCDF library(libnetcdf.a) the HDF/MFHDF distribution
      must be compiled with the option '-DHAVE_NETCDF'. This will
      rename the HDF version of the C-interface(ncxxx) of the netCDF API
      to sd_ncxxx to avoid clashing with the original netCDF API from
      libnetcdf.a. Currently there is no support for renaming the
      netCDF Fortran interface stubs.. As such the HDF/MFHDF distribution
      must be compiled without fortran support. HDF Users can still access
      HDF/netCDF files through the SDxxx interface but not through the
      ncxxx interface unless the renamed interface is used(sd_ncxxx).

As Russ mentioned, HDF4 used netCDF-2 and NOT netCDF-3.  There are
a few conflicts with building HDF 4 with netCDF-3 with this option.  A
user sent me the following on how to get around them (which I have not
verified):

  In case anyone cares: against netCDF 3.5.0, -DHAVE_NETCDF almost works
  with HDF4.1r5.  There are collisions for the netCDF globals ncerr and
  ncopt.  To make them go away, you have to change hdf2netcdf.h, adding
  the following inside the #ifdef HAVE_NETCDF:

  #define ncerr     HNAME(ncerr)   /* added to make netCDF 3.5 work */
  #define ncopts    HNAME(ncopts)  /* ditto */

  It is also necessary to change netcdf.h and win32cdf.h, since they
  define those globals before the inclusion of hdf2netcdf.h.  I just moved
  the lines:

  extern int ncerr ;
  extern int ncopts ;     /* default is (NC_FATAL | NC_VERBOSE) */

  down about 20 lines (from line 360 +/- 10).

  With those changes, my stuff links and appears to work for cursory
  testing.

With HDF4.2r0, we substantially changed the configuration, and I
don't know if you can still use the -DHAVE_NETCDF flag or not. 
If you can't, HDF 4.1r5 was a stable release and is fine to use.  

-Barbara

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Barbara Jones, HDF Helpdesk
National Center for Supercomputing Applications
University of Illinois at Urbana-Champaign

address@hidden
http://hdf.ncsa.uiuc.edu/
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+



> I'm using HDF4 and netCDF in the same program and get the following 
> conflicts. Any idea how to solve them?
> 
> thanks,
> Kurt
> 
> 
> [kurts@dmx fast-bit]$ make
> g++ -Wall -o fast HDFReader.cpp NetCDFReader.cpp FastBit.cpp 
> -I/software/netcdf-3.5.1b12/include -I/software/hdf4/include 
> -L/software/netcdf-3.5.1b12/lib -L/software/hdf4/lib  -lmfhdf -ldf 
> -ljpeg -lz -lnetcdf
> /software/netcdf-3.5.1b12/lib/libnetcdf.a(nc.o): In function `NC_check_id':
> nc.o(.text+0x6c): multiple definition of `NC_check_id'
> /software/hdf4/lib/libmfhdf.a(file.o)(.text+0x0): first defined here
> /usr/bin/ld: Warning: size of symbol `NC_check_id' changed from 100 to 
> 54 in /software/netcdf-3.5.1b12/lib/libnetcdf.a(nc.o)
> /software/netcdf-3.5.1b12/lib/libnetcdf.a(var.o): In function 
> `NC_var_shape':
> var.o(.text+0x4c8): multiple definition of `NC_var_shape'
> /software/hdf4/lib/libmfhdf.a(var.o)(.text+0x284): first defined here
> /usr/bin/ld: Warning: size of symbol `NC_var_shape' changed from 802 to 
> 272 in /software/netcdf-3.5.1b12/lib/libnetcdf.a(var.o)
> /software/netcdf-3.5.1b12/lib/libnetcdf.a(attr.o): In function 
> `NC_findattr':
> attr.o(.text+0x3bc): multiple definition of `NC_findattr'
> /software/hdf4/lib/libmfhdf.a(attr.o)(.text+0x23c): first defined here
> /usr/bin/ld: Warning: size of symbol `NC_findattr' changed from 156 to 
> 139 in /software/netcdf-3.5.1b12/lib/libnetcdf.a(attr.o)
> collect2: ld returned 1 exit status
> make: *** [fast] Error 1
> 
> 
> -- 
> Kurt Stockinger
> Scientific Data Management Group
> Lawrence Berkeley National Laboratory
> Mail Stop 50B-3238 
> 1 Cyclotron Road
> Berkeley, CA 94720, USA
> 
> Tel: +1 (510) 486 5519, Fax: +1 (510) 486 4004
> email: address@hidden
> http://sdm.lbl.gov/~kurts/
> 

------- End of Forwarded Message