Builld Project R with HDF5 on Solaris 10 x64 in 32bit

“R is a free software environment for statistical computing and graphics.” (Source) “HDF5 is a general purpose library and file format for storing scientific data.” (Source) Here are my notes on how to build from source, no special optimization flags, just straight compilation. If you want to try different configuration options, run ./configure –help will display different options available for each source tree.

0. Prerequisites
Notes presented here use Sun’s Studio 11. All compiler flags are Studio specific and not applicable to gcc. See this installation note for some tips on installing Studio 11.

1. Download the source
Below are the source packages that I used to build the binary. Download, gunzip, and un-tar these files. At the time of writing, these are the current version. You might want to double check for newer versions.
NCSA HDF5: ftp://ftp.ncsa.uiuc.edu/HDF/HDF5/current/src/hdf5-1.6.5.tar.gz
szip: ftp://ftp.ncsa.uiuc.edu/HDF/lib-external/szip/2.0/src/szip-2.0.tar.gz
R: http://cran.cnr.berkeley.edu/src/base/R-2/R-2.4.0.tar.gz
R HDF5: http://cran.cnr.berkeley.edu/src/contrib/hdf5_1.6.4.tar.gz

2. Set the following environment variables. You can put them in a text file/.profile/.cshrc and source the file. Please replace <HDF5_LIB_HOME> with the appropriate path that you want to install NCSA HDF5 library binary.

export CC=/opt/SUNWspro/bin/ccexport CXX=/opt/SUNWspro/bin/CC
export F77=/opt/SUNWspro/bin/f77
export CFLAGS="-xtarget=opteron -I<HDF5_LIB_HOME>/include"
export CXXFLAGS="-xtarget=opteron"
export  PATH=/opt/SUNWspro/bin:/usr/ccs/bin:/usr/dt/bin:/usr/xpg4/bin:/usr/bin:/opt/csw/bin
export  LD_LIBRARY_PATH=/opt/csw/lib:/usr/lib:<HDF5_LIB_HOME>/lib
export FFLAGS="-xtarget=opteron"
export FCFLAGS="-xtarget=opteron"
export LDFLAGS="-xtarget=opteron -L/usr/lib -L/opt/csw/lib"

3. Compiling szip library
szip is one of the required libraries for compiling NCSA HDF5 library. If you already have this library available on your system, you can skip this step and make sure path to its lib directory is specified with –with-szlib flag when compiling NCSA HDF5 in step 4. When following the steps specified below, replace <szip_HOME> with the path where you want to install the library binary.

make clean
./configure --prefix=<szip_HOME>szip-2.0
make
make check
make install

4. Compiling NCSA HDF5 library
Replace <szip_HOME> and <HDF5_LIB_HOME> with appropriate paths for your environment.

make clean
./configure --with-zlib=/usr --with-szlib=<szip_HOME>  --prefix=<HDF5_LIB_HOME> --enable-cxx
make
make check
make install

5. Configure R HDF5
R HDF5 is an integration between R and HDF5. You need to configure R HDF5 with the path to NCSA HDF5 library before you can ask R to install R HDF5. Before you run the configure script, make the following changes:

* Remove the following lines from configure

if test `uname -s` != "Darwin"; thenHDF5LDFLAGS="-Wl,-rpath,${with_hdf5}/lib"
fi

* Add -lz option to the following line:

LIBS=-lm

So, it looks like the following:

LIBS=-lm -lz

Remember to replace <HDF5_LIB_HOME> before running the following configure command

./configure --with-hdf5=<HDF5_LIB_HOME>  --with-zlib=/usr

The configure script will not generate a makefile. To double check if the configuration worked, look at the last line of configure.log file, which should look like the following:

configure: exit 0

If you didn’t see an exit code of 0, then configure script failed.

6. Compile R
Below are the steps to compile R. Replace <R_HOME> with the path to where you want to install R binary. –enable-static is only necessary if you expect to run multiple versions of the same library on the same system. Remove the option if the described situation doesn’t apply. Since I only expect to use R on the command line, I added –with-x=no option. If your build system doesn’t have direct access to Internet, you may get an error with Internet.R test case when running make check. This probably isn’t a big deal if you do not expect to use any feature that may need to access Internet.

make clean
./configure --prefix=<R_HOME> --enable-static --with-x=no
make
make check
make install

7. Install R HDF5
Here is the final step to install R HDF5 into R environment. Replace <PATH_TO_R_HDF5_SOURCE> with the appropriate path.

./R CMD INSTALL <PATH_TO_R_HDF5_SOURCE>

You may see the following warning messages. Since these are warnings, it might not be a major concern. If the binary starts to produce incorrect output or crash, fixes to the declarations consistent with the ISO standard prototypes in the source code maybe necessary.

"hdf5.c", line 124: warning: argument #1 is incompatible with prototype:prototype: pointer to char : "/usr/include/iso/string_iso.h",  line 72
argument : pointer to unsigned char
"hdf5.c", line 124: warning: argument #2 is incompatible with prototype:
prototype: pointer to const char :  "/usr/include/iso/string_iso.h", line 72
argument : pointer to unsigned char
"hdf5.c", line 126: warning: argument #1 is incompatible with prototype:
prototype: pointer to const char :  "/usr/include/iso/string_iso.h", line 69
argument : pointer to unsigned char
"hdf5.c", line 129: warning: argument #2 is incompatible with prototype:
prototype: pointer to const char :  "/usr/include/iso/string_iso.h", line 65
argument : pointer to unsigned char
"hdf5.c", line 512: warning: assignment type mismatch:
pointer to long long "=" pointer to unsigned long long
/opt/SUNWspro/bin/cc -G -xtarget=opteron -L/usr/lib -L/opt/csw/lib -o  hdf5.so hdf5.o -lhdf5 -lz -lm

One thought on “Builld Project R with HDF5 on Solaris 10 x64 in 32bit

Leave a comment