VEX Code V5: make process closed with exit code : 2

you need a while(true) loop around all the driver control code. At the moment your code runs once and then main exits.

6 Likes

wow i would have never thought of that its been a long time since iv’e used a while true command

2 Likes

hey, I am experiencing the same thing but I am using an autonomous program do you have any advice??

Please post your code (remember to wrap it in [code]…[/code] tags for formatting!), as well as the complete contents of the console tab when trying to compile, otherwise it’s very difficult to diagnose/debug your code.

3 Likes

I can confirm that there is no whitespace allowed in the name. I had mine named “X Drive 1”, and it would come up with exit code 2. I changed it to “XDrive1”, and it builds fine now.

1 Like

Hello all,

I am now encountering this issue with previously viable coding which has built.

I have include a copy of a code that is throwing the error.

The kid and I have no idea what is causing this. Does anyone have an idea?

#include "vex.h"
#include "robot-config.h"

using namespace vex;
using signature = vision::signature;
using code = vision::code;

// A global instance of brain used for printing to the V5 Brain screen
brain  Brain;

// VEXcode device constructors
controller Controller1 = controller(primary);
motor llb = motor(PORT1, ratio18_1, false);
motor llt = motor(PORT4, ratio18_1, false);
motor claw = motor(PORT5, ratio18_1, true);
motor rlt = motor(PORT7, ratio18_1, true);
motor rlb = motor(PORT10, ratio18_1, true);
motor lw = motor(PORT15, ratio18_1, true);
motor rd = motor(PORT16, ratio18_1, false);

// VEXcode generated functions
bool Controller1LeftShoulderControlMotorsStopped = true;
bool Controller1RightShoulderControlMotorsStopped = true;

/**
 * Used to initialize code/tasks/devices added using tools in VEXcode Text.
 * 
 * This should be called at the start of your int main function.
 */

 int rc_auto_loop_callback_Controller1() {
  // process the controller input every 20 milliseconds
  // update the motors based on the input values

  rd.setVelocity(100, percent);
  rd.setVelocity(100, percent);
  claw.setVelocity(100, percent);
  claw.setVelocity(100, percent);

  while(true){
    // check the ButtonL1/ButtonL2 status to control llb
     if (Controller1.ButtonL1.pressing()){ // L1 intake up, L2 intake down
     llb.spin(forward);
     rlb.spin(forward);
     Controller1LeftShoulderControlMotorsStopped = false;
    } else if (Controller1.ButtonL2.pressing()) {
    llb.spin(reverse);
    rlb.spin(reverse);
    Controller1LeftShoulderControlMotorsStopped = false;
    } else if (!Controller1LeftShoulderControlMotorsStopped) {
      llb.stop();
      rlb.stop();
    // set the toggle sp that we don't constantly tell the motor to stop when the buttons are released
    Controller1LeftShoulderControlMotorsStopped = true;
    }
    // check the ButtonsR1/ButtonsR2 status to control claw
    if (Controller1.ButtonR1.pressing()) { //R1 open, R2 close
    claw.spin(forward);
    claw.spin(forward);
    Controller1LeftShoulderControlMotorsStopped = false;     
    } else if (Controller1.ButtonR1.pressing()) {
    claw.spin(reverse);
    claw.spin(reverse);
    Controller1LeftShoulderControlMotorsStopped = false;
    } else if (Controller1LeftShoulderControlMotorsStopped) {
    claw.stop();
    claw.stop();
    // set the toggle sp that we don't constantly tell the motor to stop when the buttons are released
    Controller1LeftShoulderControlMotorsStopped = true;
    }
} 

void vexcodeInit( void );

 }

There’s no problem with that code as far as I can see. Paste the contents of the output tab here so we can see all the errors.

3 Likes

After the first attempt this is what the output was:

[info]: Project Path: D:\WP_Backup_1-2020-01-07T21-35-42
windows build for platform vexv5
“CXX src/main.cpp”
src/main.cpp:19:21: error: expected ‘(’ for function-style cast or type construction
vexcodeInit( void );
~~~~ ^
1 error generated.
make: *** [vex/mkrules.mk:13: build/src/main.o] Error 1
[error]: make process closed with exit code : 2

following opening the make file and changing verbose to 1 this was the output:

windows build for platform vexv5

md “build/src” 2> nul || :

“CXX src/main.cpp”

clang -target thumbv7-none-eabi -fshort-enums -Wno-unknown-attributes -U__INT32_TYPE__ -U__UINT32_TYPE__ -D__INT32_TYPE__=long -D__UINT32_TYPE__=‘unsigned long’ -march=armv7-a -mfpu=neon -mfloat-abi=softfp -Os -Wall -Werror=return-type -fno-rtti -fno-threadsafe-statics -fno-exceptions -std=gnu++11 -ffunction-sections -fdata-sections -DVexV5 -Iinclude -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/include" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/clang/8.0.0/include" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/gcc/include" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/gcc/include/c++/4.9.3" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb" -c -o build/src/main.o src/main.cpp

md “build/src” 2> nul || :

“CXX src/robot-config.cpp”

clang -target thumbv7-none-eabi -fshort-enums -Wno-unknown-attributes -U__INT32_TYPE__ -U__UINT32_TYPE__ -D__INT32_TYPE__=long -D__UINT32_TYPE__=‘unsigned long’ -march=armv7-a -mfpu=neon -mfloat-abi=softfp -Os -Wall -Werror=return-type -fno-rtti -fno-threadsafe-statics -fno-exceptions -std=gnu++11 -ffunction-sections -fdata-sections -DVexV5 -Iinclude -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/include" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/clang/8.0.0/include" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/gcc/include" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/gcc/include/c++/4.9.3" -I"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/gcc/include/c++/4.9.3/arm-none-eabi/armv7-ar/thumb" -c -o build/src/robot-config.o src/robot-config.cpp

“LINK build/WPBackup120200107T213542.elf”

arm-none-eabi-ld -nostdlib -T “C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/lscript.ld” -R “C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/stdlib_0.lib” -Map=“build/WPBackup120200107T213542.map” --gc-section -L"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5" -L"C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5/gcc/libs" -o build/WPBackup120200107T213542.elf build/src/main.o build/src/robot-config.o --start-group -lv5rt -lstdc++ -lc -lm -lgcc --end-group

build/src/main.o: In function `main’:

main.cpp:(.text.main+0x8): undefined reference to `vexcodeInit()’

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

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

ok, it looks like the issue is the call to vexcodeInit.
how is called in main ? do you have any other definitions.
this is the error you are having

“CXX src/main.cpp”
src/main.cpp:19:21: error: expected ‘(’ for function-style cast or type construction
vexcodeInit( void );
~~~~ ^

The call should just be like this.

vexcodeInit();
5 Likes

Okay after a reboot of the computer and a loss of all that output, I have adjusted all the vexcodeInit() codes to look like the call above.

here is the new error:

“CXX src/robot-config.cpp”

“LINK build/WPBackup120200107T213542.elf”

build/src/main.o: In function `main’:

main.cpp:(.text.main+0x8): undefined reference to `vexcodeInit()’

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

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

ok, I had a look at the code in robot-config.cpp again, this part is actually messed up.

void vexcodeInit( void );
 }

should be

void vexcodeInit( void ) {
}

has that file been edited or is it being auto generated still ?

6 Likes

I believe that its the generated code from the competition template. I have made the adjustment you indicated and it is giving this error:

src/robot-config.cpp:69:26: error: function definition is not allowed here void vexcodeInit( void ) { ^

the carrot is under the {

it also still codes error 2.

Ok, it’s probably going to be quicker to just zip up (export) the project and send it to me or post here, then I can see all the code and fix for you.

3 Likes

I appreciate the offer and all the help, with a lot of work, a highlighter and a two Mountain Dews I discover that the RemoteControlCodeEnable codes were missing and that was the open loop. Thanks for everyone’s help.

Hello, @jpearman. I was facing this error as well, and the output stated that I had “multiple definitions of Brain”. This was only present in the competition template, as a different program I had written by myself without the definition of “Brain” downloaded successfully. I ended up turning the line defining “Brain” as a comment, and the competition file downloaded as well. Do you know why this is the case? The competition file sample comes with a vex::brain Brain line already defined, and because I had no other errors in my program, it took me a week to figure out why it wouldn’t download! Just curious as to why it sees the brain definition as an error.

What does src mean? Should I put this before my autonomous command in the competition template?