Skip to content

Unable to cross compile for windows using mingw with 64bit labels

Summary

Unable to cross compile for windows when using 64bit labels for doublefloat.h and complexi.h

Steps to reproduce

Setup the environment with the usual flags

# [WM_COMPILER_TYPE] - Compiler location:
# = system | ThirdParty
export WM_COMPILER_TYPE=system

# [WM_COMPILER] - Compiler:
# = Gcc | Clang | Icc | Icx | Amd | Arm | Cray | Fujitsu | Nvidia |
#   Gcc<digits> | Clang<digits>
export WM_COMPILER=Mingw

# [WM_PRECISION_OPTION] - Floating-point precision:
# = DP | SP | SPDP
export WM_PRECISION_OPTION=DP

# [WM_LABEL_SIZE] - Label size in bits:
# = 32 | 64
export WM_LABEL_SIZE=64

# [WM_COMPILE_OPTION] - Optimised(default), debug, profiling, other:
# = Opt | Dbg | Debug | Prof
export WM_COMPILE_OPTION=Opt

# [WM_MPLIB] - MPI implementation:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |
#   HPMPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
# Specify SYSTEMOPENMPI1, SYSTEMOPENMPI2 for internal tracking (if desired)
# Can also use INTELMPI-xyz etc and define your own wmake rule
export WM_MPLIB=MSMPI


# [WM_OSTYPE] - Operating System Type (set automatically)
# = POSIX | MSwindows
export WM_OSTYPE=MSwindows

Example case

What is the current bug behaviour?

Compilation error when compiling quaternion.C due to pow() function not being able to handle "long long" variable due to ambiguous definition

What is the expected correct behavior?

Relevant logs and/or images

Environment information

  • OpenFOAM version : 2312
  • Operating system : openSUSE
  • Hardware info :
  • Compiler : Mingw

Possible fixes

Compiler error traced it to doubleFloat.H in one of the macros for MAXMINPOW

MAXMINPOW is not able to handle 64 bit label for WIN32 system, adding this to doubleFloat.H can fix the issue

#if defined(__WIN32__) && WM_LABEL_SIZE == 64
MAXMINPOW(double, double, int64_t)
MAXMINPOW(double, int64_t, double)
MAXMINPOW(float, float, int64_t)
MAXMINPOW(float, int64_t, float)
#endif

for complexI.H

#if defined(__WIN32__) && WM_LABEL_SIZE == 64
powFuncs(int64_t)
#endif
Edited by gng