Building/Linking hdf5 mingw

Hi,

I am trying to build an R package (www.r-project.org) for working with
hdf5. I have had no problems doing this on unix, but windows is
problematic. First, the R project uses MinGW to build on windows -- it
doesn't support building with VC. I have successfully built hdf5 using
MinGW on windows, but I am incapable of linking against the hdf5.a and
hdf5_hl.a built with MinGW. I see no way to build a dll (as in the
prebuilt hdf5 libraries downloadable from the website).

Following this thread,

http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2009-October/001860.html

I then downloaded the prebuilt windows version for 32 bit windows. I
compile against it, yielding an error for a repeated definition of
ssize_t (apparently MinGW has this defined as well) in H5Public.h
I comment this out (lineno 118 in H5Public.h in include):

#if H5_SIZEOF_SIZE_T==H5_SIZEOF_INT
//typedef int ssize_t;

It then compiles. However, then when I link against it, as follows,

PKG_LIBS = -Lc:/rwork/hdf5_prebuilt/hdf5lib/dll -l hdf5dll -l hdf5_hldll

I get a linker error:

undefined reference to _imp_H5T_C_S1_g

Indeed, when I use nm (in the dll directory)

nm hdf5dll.dll | grep H5T_C_S1

I get no results; However, on hdf5.lib (in the lib directory)

nm hdf5.lib | grep H5T_C_S1

0000000 R ??_C@_08LPEJMKOH@H5T_C_S1?$AA@
U _H5T_C_S1_g
00000090D _H5T_C_S1_g

Naturally, I have tried to link against the .libs in the lib directory
but there is an inherent incompatibility here and it finds no symbols
(probably a Visual C / MinGW incompatibility?)

So my questions are:

1.) Why cannot I link against the .a files of the version of hdf5 which
I build using MinGW?
2.) How can I build .dll files like the prebuilt version does when I
build using MinGW?
3.) How is it possible that H5T_C_S1 is not defined in the .dll?

This code runs out of the box on linux. Nothing special with the
compilers. Thanks very much in advance, any help would be greatly
appreciated.

I hope to make this generally available to the statistics community, but
a pre-requisite is to get the thing working on Windows.

thanks again, jim

Hi,

  I'm regularly building and using HDF5 built with mingw as DLL. No problems with that,
but I don't use the configure system.

You can get my version of the build system for mingw via the F5 repository

  http://f5.origo.ethz.ch/

The "Development" page on this page has the SVN url's for anonymous checkout.
You don't need the F5 library for that, but that checkout will also come with a
recent copy of the HDF5 libraries, and you might be able to derive the necessary
compilation/link flags from this configuration.

  Werner

···

On Thu, 08 Apr 2010 14:45:04 -0400, James Bullard <JBullard@pacificbiosciences.com> wrote:

Hi,

I am trying to build an R package (www.r-project.org) for working with
hdf5. I have had no problems doing this on unix, but windows is
problematic. First, the R project uses MinGW to build on windows -- it
doesn't support building with VC. I have successfully built hdf5 using
MinGW on windows, but I am incapable of linking against the hdf5.a and
hdf5_hl.a built with MinGW. I see no way to build a dll (as in the
prebuilt hdf5 libraries downloadable from the website).

Following this thread,

http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/2009-October/001860.html

I then downloaded the prebuilt windows version for 32 bit windows. I
compile against it, yielding an error for a repeated definition of
ssize_t (apparently MinGW has this defined as well) in H5Public.h
I comment this out (lineno 118 in H5Public.h in include):

#if H5_SIZEOF_SIZE_T==H5_SIZEOF_INT
//typedef int ssize_t;

It then compiles. However, then when I link against it, as follows,

PKG_LIBS = -Lc:/rwork/hdf5_prebuilt/hdf5lib/dll -l hdf5dll -l hdf5_hldll

I get a linker error:

undefined reference to _imp_H5T_C_S1_g

Indeed, when I use nm (in the dll directory)

nm hdf5dll.dll | grep H5T_C_S1

I get no results; However, on hdf5.lib (in the lib directory)

nm hdf5.lib | grep H5T_C_S1

0000000 R ??_C@_08LPEJMKOH@H5T_C_S1?$AA@
U _H5T_C_S1_g
00000090D _H5T_C_S1_g

Naturally, I have tried to link against the .libs in the lib directory
but there is an inherent incompatibility here and it finds no symbols
(probably a Visual C / MinGW incompatibility?)

So my questions are:

1.) Why cannot I link against the .a files of the version of hdf5 which
I build using MinGW?
2.) How can I build .dll files like the prebuilt version does when I
build using MinGW?
3.) How is it possible that H5T_C_S1 is not defined in the .dll?

This code runs out of the box on linux. Nothing special with the
compilers. Thanks very much in advance, any help would be greatly
appreciated.

I hope to make this generally available to the statistics community, but
a pre-requisite is to get the thing working on Windows.

thanks again, jim

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Laboratory for Creative Arts and Technology (LCAT)
Center for Computation & Technology at Louisiana State University (CCT/LSU)
211 Johnston Hall, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362