[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
}
4 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.

2 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