Compile error

I’m getting a compile error in c++.

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

If you scroll up, it will give you more information on what the error actually is.

> Task :compileFrcUserProgramReleaseExecutableFrcUserProgramCpp FAILED
C:\Users\ricar\Documents\Trabajos\Team Freedom\Software Team\Projects\FRC 2019\elpitufocpp\src\main\cpp\Robot.cpp:11:26: fatal error: rev/SparkMax.h:
No such file or directory
 #include "rev/SparkMax.h"
                          ^
compilation terminated.


FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':compileFrcUserProgramDebugExecutableFrcUserProgramCpp'.
> A build operation failed.
      C++ compiler failed while compiling Robot.cpp.
  See the complete log at: file:///C:/Users/ricar/Documents/Trabajos/Team%20Freedom/Software%20Team/Projects/FRC%202019/elpitufocpp/build/tmp/compileFrcUserProgramDebugExecutableFrcUserProgramCpp/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 ':compileFrcUserProgramReleaseExecutableFrcUserProgramCpp'.
> A build operation failed.
      C++ compiler failed while compiling Robot.cpp.
  See the complete log at: file:///C:/Users/ricar/Documents/Trabajos/Team%20Freedom/Software%20Team/Projects/FRC%202019/elpitufocpp/build/tmp/compileFrcUserProgramReleaseExecutableFrcUserProgramCpp/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 7s
2 actionable tasks: 2 executed
Compilation Error!
GradleRIO detected this build failed due to a Compile Error (compileFrcUserProgramDebugExecutableFrcUserProgramCpp).
Check that all your files are saved, then scroll up in this log for more information.
Compilation Error!
GradleRIO detected this build failed due to a Compile Error (compileFrcUserProgramReleaseExecutableFrcUserProgramCpp).
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 the complete error, i use Java but im forced to use the cpp due to the spark max libraries

A few things:

  1. Are you working with a fresh clone of the source code? (assuming you’re using GitHub or another source control provider)
  2. Is the Spark Max library included in the code, or is it an external library?
  3. If the library is included in the code, are you sure you have it?

This is the code

/*----------------------------------------------------------------------------*/
/* Copyright (c) 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/TimedRobot.h>
#include <frc/drive/DifferentialDrive.h>
#include "rev/SparkMax.h"

class Robot : public frc::TimedRobot {
  /**
   * In PWM mode, SPARK MAX controllers are intialized by creating a
   * SparkMax object and passing the PWM channel as a parameter
   * 
   * Change the PWM channels below to match your setup
   */
  rev::SparkMax m_leftMotor{0};
  rev::SparkMax m_leftMotor2{1};
  rev::SparkMax m_leftMotor3{3};

  rev::SparkMax m_rightMotor{4};
  rev::SparkMax m_rightMotor2{5};
  rev::SparkMax m_rightMotor3{5};

  frc::SpeedControllerGroup m_left{m_frontLeft, m_leftMotor2, m_leftMotor3};
  frc::SpeedControllerGroup m_right{m_rightMotor, m_rightMotor2, m_rightMotor3};


  frc::DifferentialDrive m_robotDrive{m_left, m_right};
  frc::Joystick m_stick{0};

 public:
  void TeleopPeriodic() {
    // Drive with arcade style
    m_robotDrive.ArcadeDrive(-m_stick.GetY(), m_stick.GetX());
  }
};

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

Why are you having to use c++ because of the spark max The libraries work just fine in Java.

With pwm they don’t

Check this post

Make sure you include the REV vendor library in VS Code for that project.

http://www.revrobotics.com/sparkmax-software/

With pwm you don’t have to use the spark max vendor libraries, you can just use the wpilib pwm Spark class.

1 Like