Fixed on GIT 32 bit builds not working on Windows in Release mode with MinGW

JaviCervera

Member
3rd Party Module Dev
Joined
Jul 12, 2017
Messages
80
There seems to be a problem when generating 32 bit builds of applications in Release mode in Windows. I am using the MinGW version referred in the Cerberus-X documentation (https://www.cerberus-x.com/downloads/tdm-gcc-64.zip), and to verify that the problem was not in Vortex itself, I tried building the mojo/mak/gles20cube example. I have added this to the beginning of the file before building with GLFW target:

#GLFW_GCC_MSIZE_WINNT="32"

The generated executable crashes on startup. It works in Debug mode and in all 64 bit modes.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
552
This could be the old issue dicussed here.
 

JaviCervera

Member
3rd Party Module Dev
Joined
Jul 12, 2017
Messages
80
Yes, it seems to be the same thing. It's a 2 year old thread... I guess this never got fixed. Or does another version of MinGW work?
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
552
It's been some time, but if I remember correctly a different version worked with 32Bit. I think I used two different versions to build for 32 and 64 bit.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,845
It's been some time, but if I remember correctly a different version worked with 32Bit.
I think there is but imho not a good solution because of the problem that the app crashes when you move the window in 32bit mode.

We should move to MSVC only on Windows.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
552
not a good solution because of the problem that the app crashes when you move the window in 32bit mode.
I am pretty sure, I got it working with some MinGW 32Bit release mode without any crashes, because I didn't use MSVC at that time at all and gave the app to about 20 people regularly.
You could try installing the normal mingGW or mingGW-w64 with different settings regarding threads and exception handling.
I think I can look into this at the weekend.
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
803
You'll need MinGW w64 version 6 or 7. The down side is that a number of shared gcc run time libraries need to be distributed with the executable, which would be the recommended way. But with a modification to the gcc_winnt make file template, you can build as normal.
e.g.
LDLIBS=-Wl,-Bstatic -static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive -Wl,-Bdynamic -lcomdlg32 -lgdi32 -lopengl32 $(OPENAL_DLL) $(LIBOPTS) -lws2_32

Be warned that exceptions throw by Cerberus code may cause issues with the debugger if building 64 bit applications. This is the reason why I've abandoned the changes I was going to implement that would have fixed a lot of the issues with the build system.

Edit: You''ll have to make changes to the cpp tool target as well.
 
Last edited:

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
803
It maybe worth having a look at clang again, but each version of clang requires particular version of either MinGW-w64 or Visual Studio to be installed. Which will eventually break on Windows with the next major release of Visual Studio and no MinGW-w64 counter part being released.
The only real updates currently being released for MinGW-w64 are via MSYS2.

EDIT:
clang 9 should work with VS2017
clang 10+ should work with 2019.
Both versions of clang will work with tdm-9.2 with warnings.
 
Last edited:

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,845
Wouldn't it be more simple to get msvc to output 32 and 64 bit plus console apps? This way we would have only one compiler on windows
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
803
Wouldn't it be more simple to get msvc to output 32 and 64 bit plus console apps?
Yes it would. It's not that difficult to set up a msvc project and pass arguments to output to multiple targets. But you're bound to get someone against msvc for one reason or another. I'd go for the MSVC root every time when it comes to Windows.
 

JaviCervera

Member
3rd Party Module Dev
Joined
Jul 12, 2017
Messages
80
I tried with TDM 9, but it still fails. Will check with a recent version of MinGW-W64, but I remember also having some issues with Cerberus using that.

Maybe restricting compiler support to MSVC on Windows would make things simpler, but I'd like to have an open source toolchain. For example, setting up Github Action to automatically build packages when code is pushed to the main branch is very simple, but I don't know if Github Actions supports MSVC.
 

JaviCervera

Member
3rd Party Module Dev
Joined
Jul 12, 2017
Messages
80
I want to get it working on my local computer first, but it is not being easy. I installed Visual Studio 2019, Desktop development with C++, Platform Tools v141 and Windows 8.1 SDK, but I get the following error:

fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,845
I just installed MSVC 2019 and it works fine here. Is it something related to your Vortex tools or do you get the error message with our examples too?
This is what I have installed with MSVC 2019:

1616230817429.png


I am sure that was a little overkill, like the test adapters for Boost, but that installation works for me.
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
803
Mike beat me to it. Install SDK 10!
But be warned, the Visual Installer has been known to give headaches with any tools within the SDK.
It's best to download the installers from here.
 

JaviCervera

Member
3rd Party Module Dev
Joined
Jul 12, 2017
Messages
80
@MikeHart: I get the same error with any project, Vortex or or the builtin examples :(
@dawlane: I actually have Windows 10 SDK installed. I also have tried to build a C++ "Hello world" application within VS IDE and it succeeded, but any Cerberus project fails.

Here's the installed components:

vs.png
 

JaviCervera

Member
3rd Party Module Dev
Joined
Jul 12, 2017
Messages
80
Here's the full log with one of the default examples:

"C:/Apps/Cerberus/bin/transcc_winnt" -target=Desktop_Game -config=Debug "C:/Apps/Cerberus/examples/mojo/mak/firepaint/firepaint.cxs"
TRANS cerberus compiler V2020-10-11
Parsing...
Semanting...
Translating...
Building...

Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.

Build started 3/20/2021 10:59:27 AM.

Project "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.sln" on node 1 (default targets).

ValidateSolutionConfiguration:

Building solution configuration "Debug|Win32".

Project "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.sln" (1) is building "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj" (2) on node 1 (default targets).

PrepareForBuild:

Creating directory "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\build\Debug\".

Creating directory "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\build\Debug\CerberusGame.tlog\".

InitializeBuildStatus:

Creating "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\build\Debug\CerberusGame.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.

ClCompile:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\CL.exe /c /I../curl/include /I../stb /I../openal/include /I../glfw3/include /I../glfw3/src /Zi /JMC /nologo /W0 /WX- /diagnostics:classic /Od /Oy- /D _GLFW_WIN32 /D WIN32 /D _DEBUG /D _WINDOWS /D CURL_STATICLIB /D _MBCS /Gm /EHa /MTd /GS /Gy- /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\build\Debug\\" /Fd"C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\build\Debug\vc141.pdb" /Gd /TC /analyze- /FC /errorReport:queue /bigobj ..\glfw3\src\context.c ..\glfw3\src\egl_context.c ..\glfw3\src\init.c ..\glfw3\src\input.c ..\glfw3\src\monitor.c ..\glfw3\src\osmesa_context.c ..\glfw3\src\vulkan.c ..\glfw3\src\wgl_context.c ..\glfw3\src\win32_init.c ..\glfw3\src\win32_joystick.c ..\glfw3\src\win32_monitor.c ..\glfw3\src\win32_time.c ..\glfw3\src\win32_thread.c ..\glfw3\src\win32_window.c ..\glfw3\src\window.c ..\stb\stb_image.c ..\stb\stb_vorbis.c

cl : Command line warning D9035: option 'Gm' has been deprecated and will be removed in a future release [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

stb_vorbis.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\stb\stb_vorbis.c(59): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

stb_image.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\stb\stb_image.h(305): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

window.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

win32_window.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

win32_thread.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

win32_time.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

win32_monitor.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

win32_joystick.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

win32_init.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

wgl_context.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

vulkan.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

osmesa_context.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\src\osmesa_context.c(30): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

monitor.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

input.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

init.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

egl_context.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

context.c

c:\apps\cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\glfw3\include\glfw\glfw3.h(103): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj]

Generating Code...

Done Building Project "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.vcxproj" (default targets) -- FAILED.

Done Building Project "C:\Apps\Cerberus\examples\mojo\mak\firepaint\firepaint.buildv2020-12-05\glfw3\msvc\CerberusGame.sln" (default targets) -- FAILED.


Build FAILED.

[** REMOVING ADDITIONAL LINES HERE BECAUSE THE FORUM DO NOT LET ME POST MESSAGES OVER 10000 CHARACTERS **]

Time Elapsed 00:00:02.15

TRANS FAILED: Error executing '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" /p:Configuration=Debug', return code=1

Done.
 

dawlane

Well-known member
CX Code Contributor
Joined
Jun 21, 2017
Messages
803
Two tests.
One:
Open a x86 Native Tools Command Prompt for VS 2019.​
Change directory to where the Cerberus projects CeberusGame.sln file is located and make sure that the build directory is deleted.​
Type​
Code:
MSBuild /p:Configuration=Debug /p:Platform=Win32 CerberusGame.sln
or
MSBuild /p:Configuration=Release /p:Platform=Win32 CerberusGame.sln

If it fails, then make sure that the Windows 8.1 SDK is installed correctly. As stated earlier the Visual Studio Installer has a bad habit of messing up SDK's. I always manually install them.
In VS2019 I'm sure SDK 8.1 was marked as depreciated, but the VS installer has been known to move and remove things.
If it works, then check the system and user environment variable systems search paths are in the right order.

TWO:
If you're not bothered about Windows SDK 8.1, then try opening the Cerberus projects Visual Studio sln file in the build directory into Visual Studio 2019. If it will probably ask if you want to upgrade the SDK to the latest SDK and tool chain. Do the upgrade and then use the method above to check that it's working. If it does, then upgrade the the CeberusGame.sln located in the msvc sub folders in the targets directory.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,845
I have updated the MSVC project and solution to use MSVC 2019 and SDK 10.x and loaded it up to GitHub already.
Attached is the modified project.
 

Attachments

  • msvc.zip
    35.7 KB · Views: 7

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,845
Ok, I have uploaded some changes to GitHub so you can use

#GLFW_GCC_MSIZE_WINNT="64"

also on MSVC to create 64 bit apps. We need a new app config setting like GLFW_APP_MSIZE or a separate one like GLFW_MSVC_MSIZE_WINNT.
The MSVC project is now ready for v2019. In the process I have updated CURL to version 7.75. This way, 32bit apps with the old 4.9 MingW work again on my machine (was crashing yesterday), but the crashing on dragging the window with the mouse in release mode is still a thing. :-/
To use this, you need to rebuild Transcc with the latest source on GitHub.
 
Top Bottom