Failed simulation build with desktop suppport enabled

My team was invited to an off season rookie competition, but we decided that our old robot was going to be strip for parts. As a result, we might not have a physical robot to deploy and test our code in the future.

I decided to test out the simulation feature as a alternative. To do so, I first used the official SimpleDifferentialDriveSimulation example here on GitHub.

I look up so tutorial online, and I saw a command in command palette call Simulate Robot code on Desktop as seen in this picture https://github.com/wpilibsuite/allwpilib/tree/main/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation. But in my case, I only saw the command Simulate Robot Code as seen in this photo

. I thought it would run fine because the commands are similar, and I attribute it to year to year change sinc my source is a year old. With desktop support enable, instead of taking me to the GUI, I got the following error when running the command:

 *  Executing task: gradlew simulateExternalNativeDebug   -Dorg.gradle.java.home="C:\Users\Public\wpilib\2023\jdk" 


> Task :compileFrcUserProgramWindowsx86-64DebugExecutableFrcUserProgramCpp FAILED
g++.exe: fatal error: cannot specify '-o' with '-c', '-S' or '-E' with multiple files
compilation terminated.

g++.exe: fatal error: cannot specify '-o' with '-c', '-S' or '-E' with multiple files
compilation terminated.

Compilation Error!
GradleRIO detected this build failed due to a Compile Error (compileFrcUserProgram).
Check that all your files are saved, then scroll up in this log for more information.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileFrcUserProgramWindowsx86-64DebugExecutableFrcUserProgramCpp'.
> Multiple build operations failed.
      C++ compiler failed while compiling Drivetrain.cpp.
      C++ compiler failed while compiling Robot.cpp.
  See the complete log at: file:///C:/Users/dannyk/Desktop/main/Drive%20chain%20sim%20demo/build/tmp/compileFrcUserProgramWindowsx86-64DebugExecutableFrcUserProgramCpp/output.txt
   > C++ compiler failed while compiling Drivetrain.cpp.
   > C++ compiler failed while compiling Robot.cpp.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
1 actionable task: 1 executed

The command Hardware Sim Robot Code doesn’t work either. I got the same error.

Did you install WPILib with the installer (latest stable version here), and are you using the vscode version packaged with WPILib?

Additionally, have you followed the additional installation steps for C++ simulation? It looks like gradle is using g++ (probably from mingw64), which isn’t a supported compiler on Windows.

1 Like

From what I have seen so far, the configs and versions seems to be up to day, but I can never be certain. I will put the config info here for your convince.

WPILib Information:

Project Version: 2023.4.3
VS Code Version: 1.74.2
WPILib Extension Version: 2023.4.3
C++ Extension Version: 1.13.8
Java Extension Version: 1.14.0
Java Debug Extension Version: 0.47.0
Java Dependencies Extension Version 0.21.1
Java Version: 17
Java Location: C:\Users\Public\wpilib\2023\jdk
Vendor Libraries:
    CTRE-Phoenix (Pro And v5) (23.0.12)
    WPILib-New-Commands (1.0.0)

VS code(WPILib):

Version: 1.74.2
Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
Date: 2022-12-20T10:29:14.590Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19045
Sandboxed: No

VS Build Tools config (Tools only, no IDE. Generated from export configuration command)

{
  "version": "1.0",
  "components": [
    "Microsoft.VisualStudio.Component.Roslyn.Compiler",
    "Microsoft.Component.MSBuild",
    "Microsoft.VisualStudio.Component.CoreBuildTools",
    "Microsoft.VisualStudio.Workload.MSBuildTools",
    "Microsoft.VisualStudio.Component.Windows10SDK",
    "Microsoft.VisualStudio.Component.VC.CoreBuildTools",
    "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
    "Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
    "Microsoft.VisualStudio.Component.Windows11SDK.22621",
    "Microsoft.VisualStudio.Component.VC.CMake.Project",
    "Microsoft.VisualStudio.Component.TestTools.BuildTools",
    "Microsoft.VisualStudio.Component.VC.ASAN",
    "Microsoft.VisualStudio.Component.TextTemplating",
    "Microsoft.VisualStudio.Component.VC.CoreIde",
    "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
    "Microsoft.VisualStudio.Component.Windows10SDK.20348",
    "Microsoft.VisualStudio.Workload.VCTools",
    "Microsoft.VisualStudio.Component.TypeScript.TSServer",
    "Microsoft.VisualStudio.Component.Node.Build",
    "Microsoft.VisualStudio.Workload.NodeBuildTools"
  ]
}

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22621.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64",
            "configurationProvider": "vscode-wpilib"
        }
    ],
    "version": 4
}

But the fact that you said that Gradle is not supposed to use g++ is a surprise, since the compilation fail at the subtask :compileFrcUserProgramWindowsx86-64DebugExecutableFrcUserProgramCpp, which if the name implies correctly, it should use cl.exe as its compiler, but somehow I ran into a problem with g++. Would you know a way I can get more info on what Gradle is actually doing?

And lastly, would you be able to compare my settings against yours? Maybe the VS Tools has to be a specific version?

Specifically, have you installed Visual Studio Community 2022 with the “Desktop Development with C++” component/workload? The “Build Tools” is not sufficient.

I do. I have the core desktop development with c++ module, along with some optional installation.
The below picture show the optional tools installed.

It’s somehow picking up gcc instead of msvc. Do you have some type of msys2, cygwin or mingw installed, and in PATH? Can you also post the contents of build/vscodeconfig.json? That will show us where its picking up the compiler from. If that doesn’t exist, run ./gradlew generateVsCode to make that file.

What version of Visual Studio are you using?

Oh. Reading through what you posted, you just have Build Tools. That doesn’t work. It needs to be actual VS 2022. Gradle for some reason won’t pick up build tools.

Installing VS itself did nothing. What you did remind me is that I never set up my path for MSVC. I added the following to my environment variables:

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\cl.exe
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin

Here’s the thing: Now I seem to get a different error. It’s saying I didn’t use Unicode encoding, but I did.

This is leading me to think that the problem is my paths. You did say that Mingw might be the cause. Would you be able to compare mine against yours?

C:\Users\dannyk\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\dannyk\AppData\Local\Programs\Python\Python311\
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Users\dannyk\AppData\Local\Programs\Microsoft VS Code\bin
C: \Program Files\nodejs
C:\Users\dannyk\AppData\Local\GitHubDesktop\bin;C:\Users\dannyk\mingw64\bin;C:\Users\dannyk\AppData\Roaming\npm
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\cl.exe
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin

Since * build/vscodeconfig.json* is too long, I put it over at Pastebin. Pastebin link.

Let me know if there is any other info that might help. Either way, I am quite certain that my path is the problem.

    "cppPath": "C:\\Users\\dannyk\\mingw64\\bin\\g++.exe",
    "cPath": "C:\\Users\\dannyk\\mingw64\\bin\\gcc.exe",

Yup, its picking up mingw. Remove it from your path and it should work. I’ll look and see if there is a way to make gcc never picked up for windows builds in gradle, but I’m not sure.

You don’t need to add msvc to your path. It uses a tool called vswhere to find it.

Does it work in the Developer command prompt for Visual Studio 2022?

I have removed the above code from build/vscodeconfig.json and the redundant path variables from settings. The same error remains.

I am not quite sure what “it” you are talking about. You mean WPILib VS Code? Like start an instance of it from the VS command prompt?

That vscodeconfig.json is generated by gradle. If you remove gcc from your path, it shouldn’t find it at all, but modifying that file won’t do anything.

Can you run a clean build ./gradlew clean then a build with info ./gradlew build --info and post the results of that.

Here is the output.
Pastebin link

Ok. So its now finding MSVC, but failing because the codepage for your computer is set to CP936, and theres a character in one of the eigen headers that doesn’t translate properly so it’s erroring. Thats a bug we can look into on our end, but the solution to that is probably going to be to change the codepage of your computer to english. At least for now.

Can you be more specific? Do you mean to save with a specific encoding?

And lastly, do you think a fresh install might do the trick?

Its a windows setting, not a wpilib setting.

Starting process 'command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe''. Working directory: C:\Users\dannyk\Desktop\main\Drive chain sim demo\build\objs\frcUserProgram\windowsx86-64\debug\frcUserProgramCpp Command: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe @C:\Users\dannyk\Desktop\main\Drive chain sim demo\build\tmp\compileFrcUserProgramWindowsx86-64DebugExecutableFrcUserProgramCpp\options.txt C:\Users\dannyk\Desktop\main\Drive chain sim demo\src\main\cpp\Drivetrain.cpp /FoC:\Users\dannyk\Desktop\main\Drive chain sim demo\build\objs\frcUserProgram\windowsx86-64\debug\frcUserProgramCpp\bv8allmn53jp7hrwetrf7id8i\Drivetrain.obj     
Successfully started process 'command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\cl.exe''
Drivetrain.cpp
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\Eigen\src/Core/arch/Default/Half.h(1): warning C4819: The file contains a character that cannot be represented in the current code page 
(936). Save the file in Unicode format to prevent data loss
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\Eigen\src/Core/arch/Default/BFloat16.h(1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\Eigen\src/Core/arch/Default/GenericPacketMathFunctions.h(676): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\frc/system/Discretization.h(1): warning C4819: The file contains a character that cannot be represented in the current code page (936). 
Save the file in Unicode format to prevent data loss
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\frc/system/Discretization.h(171): error C3861: 'ATn': identifier not found
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\frc/system/Discretization.h(176): error C3861: 'ATn': identifier not found
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\frc/system/Discretization.h(171): error C2065: 'ATn': undeclared identifier
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\frc/system/Discretization.h(176): error C2065: 'ATn': undeclared identifier
C:\Users\dannyk\.gradle\caches\transforms-3\062826165847ba6b02017b06274bdccb\transformed\wpimath-cpp-2023.4.3-headers\frc\geometry\Translation2d.h(1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

Thats the list of errors. Its saying the current page is 936, which is simplified chinese. If you run CHCP at a command prompt, what does it give you?

FYI looking through our code, we fixed this for 2024. Let me see if I can find a way to fix it for a 2023 project real quick.

This is from setting → language setting → administrative language setting. The non-unicode program encoding default to Chinese. Do you think that might be the cause?