Linker error due to gettimeofday when using MSVC

Hello,

I'm in the process of upgrading our HDF5 sources from 1.8.5 to 1.8.8
(both built with CMake). It worked flawlessly on Linux, but I've
encountered an oddity on Windows, where we use MSVC along with Intel's
Fortran compiler. Linkinh an application causes the linker to
complain about the symbol _gettimeofday missing in function
_HDFP_log_open. This isn't surprising, since gettimeofday is a POSIX
function and to my knowledge isn't provided by the runtime libs coming
with MSVC.

Checking the code in H5FDlog.c showed that the H5_HAVE_GETTIMEOFDAY
preprocessor symbol must be related. Searching for this string in the
hdf-1.8.5 and 1.8.8 directories lead me to the following in
release_docs/HISTORY-1_8.txt in hdf5-1.8.8

    Bug Fixes since HDF5-1.8.6

···

==========================

        - Fixed the definition of H5_HAVE_GETTIMEOFDAY on Windows so that
          HDgettimeofday() is defined and works properly. Bug HDFFV-5931
          (DER - 2011/04/14)

This is change is done for CMake in config/cmake/ConfigureChecks.cmake:

    IF (WINDOWS)
     ..
      SET (H5_HAVE_GETTIMEOFDAY 1)
      ..
    ENDIF (WINDOWS)

und for VisualStudio in windows/src/H5pubconf.h

    #define H5_HAVE_GETTIMEOFDAY 1

though I haven't tried to built using the VisualStudio files.

I'm not sure what's the right thing to do for me here. Can I just
comment out the SET (H5_HAVE_GETTIMEOFDAY 1) ? Or am I supposed to
link in a 3rd party library which provides the gettimeofday?

Best Regards,
Maik Beckmann

Maik,
   On windows using VS in 1.8.8, we include a function to provide gettimeofday. It is defined in the src\H5win32defs.h file,
look for the #ifdef H5_HAVE_VISUAL_STUDIO
section within the #ifdef H5_HAVE_WIN32_API section.

The function is sourced in the src\H5system.c file.

CMake should properly set the two defines " H5_HAVE_VISUAL_STUDIO" and "H5_HAVE_WIN32_API", check the generated H5pubconf.h in the build folder.

Allen

···

Hello,

I'm in the process of upgrading our HDF5 sources from 1.8.5 to 1.8.8
(both built with CMake). It worked flawlessly on Linux, but I've
encountered an oddity on Windows, where we use MSVC along with Intel's
Fortran compiler. Linkinh an application causes the linker to
complain about the symbol _gettimeofday missing in function
_HDFP_log_open. This isn't surprising, since gettimeofday is a POSIX
function and to my knowledge isn't provided by the runtime libs coming
with MSVC.

Checking the code in H5FDlog.c showed that the H5_HAVE_GETTIMEOFDAY
preprocessor symbol must be related. Searching for this string in the
hdf-1.8.5 and 1.8.8 directories lead me to the following in
release_docs/HISTORY-1_8.txt in hdf5-1.8.8

    Bug Fixes since HDF5-1.8.6
    ==========================

        - Fixed the definition of H5_HAVE_GETTIMEOFDAY on Windows so that
          HDgettimeofday() is defined and works properly. Bug HDFFV-5931
          (DER - 2011/04/14)

This is change is done for CMake in config/cmake/ConfigureChecks.cmake:

    IF (WINDOWS)
     ..
      SET (H5_HAVE_GETTIMEOFDAY 1)
      ..
    ENDIF (WINDOWS)

und for VisualStudio in windows/src/H5pubconf.h

    #define H5_HAVE_GETTIMEOFDAY 1

though I haven't tried to built using the VisualStudio files.

I'm not sure what's the right thing to do for me here. Can I just
comment out the SET (H5_HAVE_GETTIMEOFDAY 1) ? Or am I supposed to
link in a 3rd party library which provides the gettimeofday?

Best Regards,
Maik Beckmann

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

Ah, I see, thank you.

I can see where the confusion resulted from. The name
H5_HAVE_VISUAL_STUDIO is most likely based on the assumption that
whenever the MicroSoft Visual C compiler (MSVC) is used, Visual Studio
is used.
- Windows => Visual Studio
- Non Windows => autotools

However, with CMake you can generate Visual Studio project files for
C/C++ (*.vcproj) and Fortran (*.vfproj), NMake Makefiles or Unix
Makefiles (cygwin) to build with MSVC.

Having CMake define H5_HAVE_VISUAL_STUDIO would work, but I suggest we
move to an accurate symbol name to avoid future confusion. That would
be
- H5_HAVE_MSVC

Best,
Maik

···

2012/2/6 Allen D Byrne <byrn@hdfgroup.org>:

Maik,

On windows using VS in 1.8.8, we include a function to provide gettimeofday.
It is defined in the src\H5win32defs.h file,

look for the #ifdef H5_HAVE_VISUAL_STUDIO

section within the #ifdef H5_HAVE_WIN32_API section.

The function is sourced in the src\H5system.c file.

CMake should properly set the two defines " H5_HAVE_VISUAL_STUDIO" and
"H5_HAVE_WIN32_API", check the generated H5pubconf.h in the build folder.

or we just use the symbol defined by the MSVC itself

  #ifdef _MSC_VER
  ...
  #endif /* _MSC_VER */

···

2012/2/6 Maik Beckmann <beckmann.maik@googlemail.com>:

- H5_HAVE_MSVC