[error]: make process closed with exit code : 2

MyProject123.zip (23.7 KB)

I attached a copy of a small code I made while trying yo fix this error. I am getting this error also on my main code and I can’t understand why. I keep having this error: “[error]: make process closed with exit code : 2”. How do I fix this? I am completely stumped. I am updated to the current version if that helps.

It seems to be a problem with your motor and controller initialization. robot-config.h is only for setting the brain, motor and controller to extern. robot-config.cpp should be for initializing the motor, controller and brain.

This is what should be in robot-config.h

using namespace vex;
extern brain Brain;
extern motor MotorOne;
extern motor MotorTwo;
extern controller Controller1;
/**
 * Used to initialize code/tasks/devices added using tools in VEXcode Text.
 *
 * This should be called at the start of your int main function.
 */
void vexcodeInit(void);

This is what should be in robot-config.cpp

#include "vex.h"
using namespace vex;
// A global instance of brain used for printing to the V5 brain screen
brain Brain;
motor MotorOne = motor (PORT2, gearSetting::ratio18_1, true);
motor MotorTwo = motor(PORT4, gearSetting::ratio18_1, false);
controller Controller1 = controller(primary);
/**
* Used to initialize code/tasks/devices added using tools in VEXcode Text.
* This should be called at the start of your int main function.
*/
void vexcodeInit(void) {
// Nothing to initialize
}
5 Likes

and just to add, you have to look at the errors in the output above the make error. make will always exit with an error if the compiler or linker has an error.

LINK build/MyProject123.elf
build/src/robot-config.o:(.bss.Controller1+0x0): multiple definition of `Controller1'
build/src/main.o:(.bss.Controller1+0x0): first defined here
build/src/robot-config.o:(.bss.MotorOne+0x0): multiple definition of `MotorOne'
build/src/main.o:(.bss.MotorOne+0x0): first defined here
build/src/robot-config.o:(.bss.MotorTwo+0x0): multiple definition of `MotorTwo'
build/src/main.o:(.bss.MotorTwo+0x0): first defined here

This is telling you that you have globals variables declared more than once.
@thorstenl312 has the right approach, also see this.

3 Likes

I did that and it fixed the error I was having but brought up three more. Thanks for fixing the one (that was very very helpful), but now its saying I redefined MotorOne, MotorTwo, and Controller1 in robot-config.cpp. How do I fix this error? It says it is a redefinition of when I stated those in robot-config.h.

Really? I have tested it and it builds fine for me.
image
image

code Code2

This is the errors I am getting.

There’s a white circle next to robot-config.h which means u need to save the program first.

1 Like

I saved it and it still didn’t go away.

just reopen the project, the linter is confusued.

1 Like

It worked. Thanks guys!

1 Like

I am also having this error please help me fix it I have tried fixing it myself and cannot figure it out.
Here is my code:

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       C:\Users\Chad Montgomery                                  */
/*    Created:      Tue Oct 06 2020                                           */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Controller1          controller                    
// Leftmotorback        motor         5               
// Rightmotorback       motor         19              
// Rightreelin          motor         2               
// Leftreelin           motor         3               
// Armmotor             motor         6               
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();
  while(true) {
      Brain.Screen.clearScreen(color::blue);
      Brain.Screen.drawCircle(50,50,20,color::red);

      if (Controller1.ButtonR2.pressing()) {
        Forward();
      }

      while (Controller1.ButtonL2.pressing()) {
        Backward();
      }

      //Torque
      Rightmotorback.setMaxTorque(75, pct);
      Leftmotorback.setMaxTorque(75, pct);
      
      //Turning
      Leftmotorback.spin(directionType::fwd, Controller1.Axis1.value(), pct);
      Rightmotorback.spin(directionType::rev, Controller1.Axis1.value(), pct);

      //Arm Motor
      Armmotor.spin(directionType::fwd, Controller1.Axis3.value(), pct);
      Armmotor.spin(directionType::rev, Controller1.Axis3.value(), pct);
    
      if(Controller1.ButtonX.pressing()){
        Rightreelin.spin(directionType::rev,100,velocityUnits::pct);
        Leftreelin.spin(directionType::fwd,100,velocityUnits::pct);
      }
      
      else if(Controller1.ButtonB.pressing()){
        Rightreelin.spin(directionType::fwd,100,velocityUnits::pct);
        Leftreelin.spin(directionType::rev, 100, velocityUnits::pct);       
      }

      //Driving brake type Hold
      else if(Controller1.ButtonL1.pressing()) {
        Leftmotorback.stop(brakeType::hold);
        Rightmotorback.stop(brakeType::hold);  
      }

      //Driving brake type coast
      else if(Controller1.ButtonR1.pressing()) {
        Leftmotorback.stop(brakeType::coast);
        Rightmotorback.stop(brakeType::coast);  
      }

      //Brake Types
      else {
        Rightreelin.stop(brakeType::hold);
        Leftreelin.stop(brakeType::hold);
        Armmotor.stop(brakeType::hold);
      }
    }
  }

Here is my output and the error:
[info]: Saving Project …

[info]: Project saved!

windows build for platform vexv5

“CXX src/main.cpp”

“LINK build/TRexOfficialCode2vex.elf”

build/src/robot-config.o: In function `Forward()’:

robot-config.cpp:(.text._Z7Forwardv+0x0): multiple definition of `Forward()’

build/src/main.o:main.cpp:(.text._Z7Forwardv+0x0): first defined here

build/src/robot-config.o: In function `Backward()’:

robot-config.cpp:(.text._Z8Backwardv+0x0): multiple definition of `Backward()’

build/src/main.o:main.cpp:(.text._Z8Backwardv+0x0): first defined here

make: *** [vex/mkrules.mk:18: build/TRexOfficialCode2vex.elf] Error 1

[error]: make process closed with exit code : 2

Can you post your robot-config.cpp? Also, if you have custom functions, i would recommend only defining it at the beginning of main.cpp after all motors are initialized.

1 Like

You probably have functions in a header.

3 Likes

Issue has been solved thanks for the help.