简体   繁体   中英

HYPRE blas build error with VS 2015

I installed VS 2015 Professional. I installed the latest HYPRE, from the Lawrence Livermore website . I then configured it using CMake and proceeded to build, and I started getting BLAS ( dnrm2.c ) build errors:

2>         dnrm2.c
2>     1>
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\math.h(454): error C2059: syntax error: '('

The line of code triggering the error in dnrm2.c is:

#include "math.h"

which points to the file:

c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\math.h

I looked up this error and found some suggestions such as this to change the include to:

#include <cmath>

and to edit the HYPRE project settings in: Configuration > C/C++ > Advanced > Compile As to Compile As C++ (/TP)

which I did, but I still see same error, since apparently the same header path to math.h is included from cmath as well:

#else /* _STD_USING */
 #include <math.h>
#endif /* _STD_USING */

I've even tried re-installing VS 2015 without any luck (same errors). Appreciate any ideas on what's going on here, and how to resolve this. I guess I could try a minimalist example in VS 2015 that includes the math.h and report back, if that helps.

EDIT My minimalist example:

#include "math.h"

int main() {
  double d1 = sqrt(4.0);
  float d2 = abs(4.0);
  return 0;
} 

appears to be building OK. I tried to set the project the same way to Compile as C (or C++, didn't matter). This doesn't really help me though.

OK, the problem here is with HYPRE source it looks like. They have this in a file f2c.h included before including the math.h :

//#undef abs
//#define abs(x) ((x) >= 0 ? (x) : -(x))
//#endif

When I commented it out (since this is already defined in the standard), then it gets past that build error. Of course I run into other build errors. I'm trying to tackle those separately.

EDIT: It's not as simple as that because they (HYPRE) actually rely on their own definition of abs . So I had undo the above and change the order of some includes so that the undef actually made sense. Either way, this is a HYPRE source code problem.

If you succeed in compiling the HYPRE on VS2015, Could you send your VS2015 program to me! My major is Geophysics modeling and inversion. MY email is schoolhui@hotmail.com Thank you very much!

I've just commented

_Check_return_ int       __cdecl abs(_In_ int _X);

in

c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\math.h

and then HYPRE was successfully compiled!

Then, I've uncommented "abs".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM