3.15.4 configure/os/CONFIG_SITE.windows-x64 contains these lines:
# 64-bit Visual Studio 2010 builds fail when built optimized.
# If you are using a newer version you can try removing this:
HOST_OPT = NO
These lines are present because src/ioc/rsrv/online_notify.c crashes the linker when it is compiled with optimization. The problem with setting HOST_OPT=NO is that programs will
then be compiled with the /MTd switch, which causes them to be linked by default with the LIBCMTD library. LIBCMTD is incompatible with the LIBCMT library that the hdf5 library and other “vendor libraries” may use. HOST_OPT=NO also disables optimization when
compiling all files, which is not necessary.
I have fixed the problem by doing the following:
- Comment out the line HOST_OPT = NO in configure/os/CONFIG_SITE.windows-x64
- Make the following patch to src/ioc/rsrv/online_notify.c.
corvette:src/ioc/rsrv>diff -U3 online_notify.c.orig online_notify.c
--- online_notify.c.orig 2016-09-06 17:26:02.828605405 -0500
+++ online_notify.c 2016-09-06 18:16:52.955345453 -0500
@@ -35,6 +35,11 @@
+/* Turn off global optimization for 64-bit MSVC builds on Visual Studio 2010 */
+#if defined(_WIN32) && defined(_M_X64) && _MSC_VER==1600 && !defined(_MINGW)
+# pragma optimize("g", off)
Note that this patch is very similar to the code already present in src/libCom/calc/calcPerform.c, except that calcPerform.c does not restrict the optimization suppression to Visual
Studio 2010. I am not certain what versions of Visual Studio cause problems with calcPerform.c.
/* Turn off global optimization for 64-bit MSVC builds */
#if defined(_WIN32) && defined(_M_X64) && !defined(_MINGW)
# pragma optimize("g", off)
Both of these workarounds could probably be further improved by only disabling optimization for static builds, not for dynamic builds.
These changes allow building base 3.15.4, and all of the required code for ADCore and ADExample for windows-x64-static with no errors.