C++ new project

So I’m just tinkering around with C++. Not my primary language.

Every time I create a new project in VS code using the template generator the build fails with multiple errors. Is this normal. I haven’t even written any code yet and the build fails.

Did a fresh installation of WPILib’s VS code. Don’t see anything in the docs having to do anything special. Latest build, Windows 10, log file included below

See file:///C:/Users/Public/wpilib/test/build/tmp/compileFrcUserProgramTestWindowsx86-64ReleaseGoogleTestExeFrcUserProgramCpp/output.txt for all output for compileFrcUserProgramTestWindowsx86-64ReleaseGoogleTestExeFrcUserProgramCpp.
compiling Robot.cpp failed.
Robot.cpp
C:\Users\Public\wpilib\test\src\main\include\Robot.h(7): fatal error C1083: Cannot open include file: ‘optional’: No such file or directory
cl : Command line warning D9002 : ignoring unknown option ‘/std:c++20’
cl : Command line warning D9002 : ignoring unknown option ‘/permissive-’
cl : Command line warning D9002 : ignoring unknown option ‘/Zc:__cplusplus’
cl : Command line warning D9002 : ignoring unknown option ‘/Zc:preprocessor’

compiling RobotContainer.cpp failed.
RobotContainer.cpp
C:\Users\neeba.gradle\caches\transforms-3\9c6bb2103a3d82450f87644c2c782003\transformed\wpilibNewCommands-cpp-2023.4.3-headers\frc2/command/CommandPtr.h(10): fatal error C1083: Cannot open include file: ‘span’: No such file or directory
cl : Command line warning D9002 : ignoring unknown option ‘/std:c++20’
cl : Command line warning D9002 : ignoring unknown option ‘/permissive-’
cl : Command line warning D9002 : ignoring unknown option ‘/Zc:__cplusplus’
cl : Command line warning D9002 : ignoring unknown option ‘/Zc:preprocessor’

Finished compileFrcUserProgramTestWindowsx86-64ReleaseGoogleTestExeFrcUserProgramCpp, see full log file:///C:/Users/Public/wpilib/test/build/tmp/compileFrcUserProgramTestWindowsx86-64ReleaseGoogleTestExeFrcUserProgramCpp/output.txt.

This does not look usual to me. The errors look as though C++ compiler/headers are not right somehow. Did you choose any non-default options when you did the fresh install? Maybe send a link to the instructions you followed?

Command Based Advanced (no skeleton). Turned the simulator on.

Other than that nothing out of the ordinary (to me at least)

Worked now with no simulator option checked. I knew I had to install that separately with VS build tools and such, but didn’t think selecting it would prevent a build.

1 Like

You need Visual Studio 2022 installed to build for desktop. It looks like you probably have an older version installed (2019?).

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.