Problems compiling HDF5 with 6.1

I installed PGI 6.1 on a machine running Centos 4.3. Centos is derived from Red Hat Enterprise Linux and is the basis for the ROCKS cluster distribution, which we run on our clusters. I am trying to compile one of the libraries we provide for users, HDF5 1.6.5 (this is the latest stable version). The configure line is

./configure --prefix=/opt/hdf5/pgi --enable-fortran --enable-cxx --disable-shared --enable-static

The result is
pgCC -I. -I…/src -I./…/src -I…/…/test -I…/…/src -I…/…/src -D_BSD_SOURCE -D_POSIX_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -c tfile.cpp -o tfile.o
“tfile.cpp”, line 484: error: identifier “offsetof” is undefined
comp_type.insertMember(“a”, HOFFSET(s1_t, a), PredType::NATIVE_INT);
^

1 error detected in the compilation of “tfile.cpp”.


HDF5 compiles without problems with Intel 9.1.

I’ve tried fiddling with copying stddef.h into PGI’s include directory but that hasn’t helped.

Hi kholcomb,

Another user had the same issue (See Here) and was able to work around it by adding the following to “tfile.cpp”.

#ifndef __offsetof__
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif

The issue is that “offsetof” is a non-standard feature which pgCC does not yet support. The above definition is how offsetof was defined before it was internalized by GNUC. Note that if you get a redefinition warning, it can be safely ignored.

  • Mat

I tried adding those lines and I got:

pgCC -I. -I…/src -I./…/src -I…/…/test -I…/…/src -I…/…/src -D_BSD_SOURCE -D_POSIX_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -c tfile.cpp -o tfile.o
“/usr/pgi/linux86/6.1/include/stddef.h”, line 418: warning: incompatible
redefinition of macro “offsetof” (declared at line 26 of “tfile.cpp”)
#define offsetof(TYPE, MEMBER)
^

“tfile.cpp”, line 488: error: identifier “offsetof” is undefined
comp_type.insertMember(“a”, HOFFSET(s1_t, a), PredType::NATIVE_INT);
^

1 error detected in the compilation of “tfile.cpp”.

So I got a redefinition warning, as expected, and a fatal error.

I’m running kernel 2.6.9-34.107.plus.c4, glibc 2.3.4, and gcc 3.4.5 if that’s any help.

Hi kholcomb,

I was able to recreate the error on a RHEL 4.0 system and found when I added the offsetof definition to “src/H5Tpublic.h”, “tfile.cpp” compiled successfully. Add it to line 24 just before the line which defines HOFFSET.

From hdf5-1.6.5/src/H5Tpublic.h

/* Public headers needed by this file */
#include "H5public.h"
#include "H5Ipublic.h"

#if __PGI
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif

#define HOFFSET(S,M)    (offsetof(S,M))
  • Mat

Thanks, that fixed it.