Compilation Error in VS Code!

My c++ code will not compile in VS Code. It worked fine in eclipse, but for some reason, it refuses to work in Visual Studio. This is the message:
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.

When I scroll up to the log, it takes me to a txt file that points at my class Robot and says ‘redefinition of class Robot’.

Does anyone know how to solve this?

Any chance you can provide screenshots or an excerpt of your code to help debug?

/----------------------------------------------------------------------------/
/* Copyright © 2017-2018 FIRST. All Rights Reserved. /
/
Open Source Software - may be modified and shared by FRC teams. The code /
/
must be accompanied by the FIRST BSD license file in the root directory of /
/
the project. /
/
----------------------------------------------------------------------------*/

#include <frc/Joystick.h>
#include <frc/WPILib.h>
#include <frc/PWMTalonSRX.h>
#include <frc/Compressor.h>
#include <frc/TimedRobot.h>
#include <frc/RobotDrive.h>
#include <frc/WPILib.h>
#include <ctre/Phoenix.h>

/**

  • This sample program shows how to control a motor using a joystick. In the
  • operator control part of the program, the joystick is read and the value is
  • written to the motor.
  • Joystick analog values range from -1 to 1 and speed controller inputs as
  • range from -1 to 1 making it easy to work together.
    */
    class Robot : public frc::TimedRobot {
    public:
    void TeleopPeriodic() {
    comp->SetClosedLoopControl(true);
    m_motor.Set(0.1);
    }

private:
frc::Joystick m_stick{0};
frc::PWMTalonSRX m_motor{1};
frc::Compressor *comp = new frc::Compressor(0);
};

#ifndef RUNNING_FRC_TESTS
int main() { return frc::StartRobot(); }
#endif

So now the code successfully builds and deploys, however, all I am trying to do is set a motor to 0.1. This does not happen. How do I use the talons to set a motor to 0.1?

Yes. I am having the same error when I run the program. Worked perfectly normal on eclipse, its just on VS

Post the whole error message of what’s happening.

Also, it’s not possible to open a project between vscode and eclipse for c++. You’ll have to run the eclipse importer to move your eclipse project to vscode.

Oh but I have the eclipse file on another computer. We recently got a new laptop and it is on the new laptop that I installed the VS how would I move it over?

Here is the full error message. I did the importing from Eclipse and am still getting the same error message.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ‘:compileFrcUserProgramLinuxathenaDebugExecutableFrcUserProgramCpp’.

A build operation failed.
C++ compiler failed while compiling Robot.cpp.
See the complete log at: file:///C:/Users/bryan/Desktop/FirstDeepSpace2019/build/tmp/compileFrcUserProgramLinuxathenaDebugExecutableFrcUserProgramCpp/output.txt

  • 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.
    ==============================================================================

2: Task failed with an exception.

  • What went wrong:
    Execution failed for task ‘:compileFrcUserProgramLinuxathenaReleaseExecutableFrcUserProgramCpp’.

A build operation failed.
C++ compiler failed while compiling Robot.cpp.
See the complete log at: file:///C:/Users/bryan/Desktop/FirstDeepSpace2019/build/tmp/compileFrcUserProgramLinuxathenaReleaseExecutableFrcUserProgramCpp/output.txt

  • 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 6s
2 actionable tasks: 2 executed
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.
The terminal process terminated with exit code: 1

That’s not the full log, scroll up more and it will show you where the error has occurred

Is it this?

Task :compileFrcUserProgramLinuxathenaReleaseExecutableFrcUserProgramCpp FAILED

Do you want the whole thing perhaps?

Copy that and go to file explorer and paste it in the place of the file path.

Sorry, bu tin place of what file. I am a little new to this.

Nvm I see it. When I do it all I see is this

In file included from C:\Users\bryan\Desktop\FirstDeepSpace2019\src\main\cpp\Robot.cpp:5:0:
C:\Users\bryan\Desktop\FirstDeepSpace2019\build\tmp\expandedArchives\wpilibc-cpp-2019.1.1-headers.zip_bbc5901b0e22ac527e7d642f2ec68009/LiveWindow/LiveWindow.h:14:2: warning: #warning is a GCC extension
#warning “LiveWindow/LiveWindow.h is deprecated; include frc/livewindow/LiveWindow.h instead”

And more of this but I cant paste it. Chief Delphi is saying I cant put 2 links in a reply

Yeah, so at the top, your include statement in your code should be
#include <frc/livewindow/LiveWindow.h>

One thing you could try and do, is use Gradle, to compile. You could open Gradle in VSCode, and type ‘gradle build’. See if that works