godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.89k stars 20.15k forks source link

Windows MINGW Build enable_virtual_terminal_processing not found #58595

Open m21-cerutti opened 2 years ago

m21-cerutti commented 2 years ago

Godot version

3.4.3-stable

System information

Windows 10 / MINGW 8.1.0 / Intel Core i7-8700 AMD64

Issue description

When trying to compile with MINGW from sources, there is an error during the process. I have verified that Visual Studio have installed Window SDK 10, and all the recommendation from the documentation. I have also gcc that is in the PATH (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

The error:

+ scons platform=windows bits=64 use_mingw=yes -j9
scons: Reading SConscript files ...
Configuring for Windows: target=debug, bits=64
Using MinGW
Checking for C header file mntent.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
Compiling ==> platform\windows\os_windows.cpp
...
Compiling ==> thirdparty\bullet\BulletCollision\NarrowPhaseCollision\btPersistentManifold.cpp
=====
b"platform\\windows\\os_windows.cpp: In member function 'bool OS_Windows::_is_win11_terminal() const':\nplatform\\windows\\os_windows.cpp:2236:21: error: 'ENABLE_VIRTUAL_TERMINAL_PROCESSING' was not declared in this scope\n   return ((dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == ENABLE_VIRTUAL_TERMINAL_PROCESSING);\n                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nplatform\\windows\\os_windows.cpp:2236:21: note: suggested alternative: 'MM_SPECTRUM_SIGNAL_PROCESSING'\n   return ((dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == ENABLE_VIRTUAL_TERMINAL_PROCESSING);\n                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n                     MM_SPECTRUM_SIGNAL_PROCESSING\n"
=====
Compiling ==> thirdparty\bullet\BulletCollision\NarrowPhaseCollision\btRaycastCallback.cpp
Compiling ==> thirdparty\bullet\BulletCollision\NarrowPhaseCollision\btSubSimplexConvexCast.cpp
Compiling ==> thirdparty\bullet\BulletCollision\NarrowPhaseCollision\btVoronoiSimplexSolver.cpp
Compiling ==> thirdparty\bullet\BulletCollision\NarrowPhaseCollision\btPolyhedralContactClipping.cpp
scons: *** [platform\windows\os_windows.windows.tools.64.o] Error 1
Compiling ==> thirdparty\bullet\BulletDynamics\Character\btKinematicCharacterController.cpp
scons: building terminated because of errors.
[Time elapsed: 00:00:10.590]

Steps to reproduce

Try to compile with my configuration and this script :

#!/bin/bash -e
mkdir -p ./GodotEngine
cd ./GodotEngine
myRepo=$(pwd)

VERSION=3.4.3-stable
CORES=9

echo "Version $VERSION"

if [  ! -d "$myRepo/godot"  ]; then
    echo "cloning godot"
    git clone --branch $VERSION https://github.com/godotengine/godot
else
    cd godot
    git checkout $VERSION
    cd ..
fi

pushd godot
set -x
scons platform=windows bits=64 use_mingw=yes -j$CORES

setx GODOT_DIR "$myRepo\godot"
setx GODOT_BUILD "bin"
echo "Add %GODOT_DIR% to user environment path."
popd

Minimal reproduction project

No response

bruvzg commented 2 years ago

have verified that Visual Studio have installed Window SDK 10, and all the recommendation from the documentation.

MinGW do not use Windows SDK or Visual Studio in any way.

I have also gcc that is in the PATH (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

GCC version is irrelevant, but GCC 8.x is 4 years old and might be shipped with the old MinGW headers 6.0.0.

ENABLE_VIRTUAL_TERMINAL_PROCESSING should be available in the MinGW headers 7.0.0+ (current version is 9.0.0).

m21-cerutti commented 2 years ago

Sorry i made a mistake, it was the MingW version that is 8.0.1.

akien-mga commented 2 years ago

ENABLE_VIRTUAL_TERMINAL_PROCESSING should be available in the MinGW headers 7.0.0+ (current version is 9.0.0).

I can confirm, here's the commit which added it: https://github.com/mirror/mingw-w64/commit/1b29d1bc58910a4c21ff2c5c804bf06821032348 It's included in 7.0.0 onwards.

Sorry i made a mistake, it was the MingW version that is 8.0.1.

Does adding #include <wincon.h> in platform/windows/os_windows.cpp fix it for you?

If not, can you check if your MinGW's sys-root/mingw/include/wincon.h has a definition for ENABLE_VIRTUAL_TERMINAL_PROCESSING?

bruvzg commented 2 years ago

Does adding #include

Including windows.h should be enough, but I guess WIN32_LEAN_AND_MEAN might work differently on MinGW and MSVC, include it should not cause any issues on both. Probably we can add the header directly.

m21-cerutti commented 2 years ago

Thanks for your response, adding wincon.h or windows.h have not worked, and for Mingw i have maybe a begining of answer.

My wincon.h is was in C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\x86_64-w64-mingw32\include , and doesn't contain a definition for ENABLE_VIRTUAL_TERMINAL_PROCESSING. Since it appears suspect i have reinstalled mingw64 with now with this configuration from https://sourceforge.net/projects/mingw-w64/ 2022_03_07_19-42-53_Installing_MinGW-W64

But no definition again for ENABLE_VIRTUAL_TERMINAL_PROCESSING. I think for this problem it's because i don't have build from the sources of mingw but it seems weird.

bruvzg commented 2 years ago

https://sourceforge.net/projects/mingw-w64/ Source: README.rst, updated 2018-05-24

There are recent files in this repo, but the installer seems to be outdated (if it's from 2018, most likely it is MinGW v6.0.0 or v5.0.4 with GCC 8.1.0). There's no MinGW 8.1.0 release at all - see https://www.mingw-w64.org/changelog/

I would suggest using https://www.msys2.org/ to install MinGW.

m21-cerutti commented 2 years ago

Ok seems it has solve the problem. Thanks you ! Maybe it would be nice to add it to the documentation ? Maybe some kind of verification or warning about the MingW version needed like for the posix thread model ?

piiertho commented 2 years ago

Don’t know if it is linked, as we don’t use mingwin, but we experience same error on latest windows GitHub runner: https://github.com/utopia-rise/godot-kotlin-jvm/runs/5588451500?check_suite_focus=true

bruvzg commented 2 years ago

Don’t know if it is linked, as we don’t use mingwin

From this log, it's clear that it is using MinGW. Even if you have not specified use_mingw for the scons it will use it if MinGW is found and Visual Studio is not.

piiertho commented 2 years ago

Don’t know if it is linked, as we don’t use mingwin

From this log, it's clear that it is using MinGW. Even if you have not specified use_mingw for the scons it will use it if MinGW is found and Visual Studio is not.

Oh thanks ! Never noticed the using mingwin log on our jobs.

EDIT: here is a previous log on our side: https://github.com/utopia-rise/godot-kotlin-jvm/runs/4828315772?check_suite_focus=true It was using MSVC as default. So it seems default behaviour on GitHub runners has changed. This won’t cause trouble to this repo CI ?

GKxxQAQ commented 5 months ago

@bruvzg Is there a predefined macro that can tell the version of the mingw headers?

akien-mga commented 5 months ago

@bruvzg Is there a predefined macro that can tell the version of the mingw headers?

#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 7