Shared libraries support and some other
support issues for HDF4
Elena Pourmal
December 5, 2004
“The devil is not as frightful as he is painted”
Russian proverb
I decided to document what I learned while trying to create shared HDF4 libraries based on the HDF4r2.0-post0 release. If we decide to go ahead and support shared libraries at some point in the future, this document should give a quick start to anyone (including me) assigned to do the project.
1. The need for shared HDF4 Libraries
I came up with the three needs that justify the support of the HDF4 shared libraries
Bob already implemented this approach in HDF5 (http://hdf.ncsa.uiuc.edu/RFC/SZIP/Szip_dynamic_12_Oct.pdf). As a result we need to build only one binary of the HDF5 library during the release time. Users may download SZIP with encoder or SZIP without encoder and do not need to worry about recompiling our library.
Currently IDL doesn’t use shared HDF libraries. This causes problems to the IDL-HDF users who cannot get fixes for their IDL application when the fix is available from HDF but have to wait until a new release of the IDL software. The question of better support came up during the HDF-EOS VIII meeting last October (Cheryl Craig).
Currently HDFView supports only HDF5 on MAC OSX. One of the requirements to support HDF4 is to have a shared HDF4 library. I believe this is a very high priority task since many NASA users use the platform.
2. Changes to the source
Since we use Automake in HDF4 starting with HDF4r2.0, it is very easy to add support for at least C shared libraries (that will satisfy all three needs mentioned above). Needed changes are described in the section 5 of the GNU Libtool Manual “Integrating libtool with your package” (http://www.gnu.org/software/libtool/manual.html). In a nutshell one has to do the following steps:
For example in hdf/src/Makfile.am the following change has to be done (old macro is commented out)
#lib_LIBRARIES = libdf.a
lib_LTLIBRARIES = libdf.la
…..
#libdf_a_SOURCES = $(CSOURCES)
libdf_la_SOURCES = $(CSOURCES)
We can use versioning bu specifying
libdf_la_LDFLAGS = -version-info 0:0:0 ( we can use real version number instead of 0:0:0)
All tests and utilities will use *.la files instead of *.a on the corresponding lines in the Makefile.am file.
/usr/bin/libtoolize –c
This command will copy ltmain.sh to the bin directory (we have config.guess and config.sub files already)
--enable-shared –disable-fortran configure flag.
You may download source tar ball with all changes mentioned above from ftp://ftp.ncsa.uiuc.edu/HDF/pub/outgoing/epourmal/HDF4_shared
3. Current status and problems
After implementing all steps
described in the section 2, I successfully built and tested HDF4 C shared
libraries on Solaris 2.7 (arabica), Linux 2.4-21 (heping), HPUX-11.00 (kelgia),
OSF1 V5.1 (lemieux), tungsten with gcc compiler (icc had problems with JPEG I
used)
On MacOSX (pommier) I had to
modify Makefile in hdf/src and mfhdf/src to replace F77LINK with LINK variable
on the lines with libdf.la target and libmfhdf.la target correspondingly. Then
build succeeded and all tests passed.
On AIX 5.1 (copper) I had a
lot of configuration problems with JPEG that I didn’t understand and would need
more time.
On all tested platforms
default configuration (static with fortran) passed.
4. Recommendations for further HDF4 configuration work
I think the following should be done to enhance HDF4 configuration and support shared libraries:
·
Split C and
Fortran libraries to avoid linking problems (1 week)
Unfortunately this will create at least 2 (and 4 when we add shared Fortran support) extra libraries libdf_fortran.so (a) and libmfhdf_fortran.so(a). This can be avoided by combining df and mfhdf libraries in one libhdf4.so (a) library, and having fortran libhdf4_fortran.so(a) (as we have in HDF5).
Technical questions: how can we smooth transition for the users
from libdf… to libhdf4…? Can we do it in a way that users’ makefiles will not
be broken?
·
Support C shared
libraries (2 weeks including testing)
·
Use
AC_FC_WRAPPERS macro to support Fortran to C name translation (3 weeks , many
unknowns, a lot of testing, but worth doing)
·
Add support for shared Fortran HDF4 libraries
(time is unknown, can be done on platform by platform, some platforms may be
not supported)
·
Eliminate hdfi.h
file (is it possible to define all datatypes we need at the configuration
time?) (Hard, I have no clue at this point how much time it may take, but this
will tremendously improve HDF4 support for the new platforms and compilers)