Code issues #include "vex.h"

I’m trying to use the vex visual studio to write code, however I keep getting this error. Does anyone know how to remedy this?

(here is my code)

#include "vex.h"

using namespace vex;

//#region config_globals
vex::brain      Brain;
vex::motor      Ld(vex::PORT1, vex::gearSetting::ratio18_1, false);
vex::motor      Ld2(vex::PORT2, vex::gearSetting::ratio18_1, false);
vex::motor      Rd(vex::PORT3, vex::gearSetting::ratio18_1, true);
vex::motor      Rd2(vex::PORT4, vex::gearSetting::ratio18_1, true);
vex::motor      F(vex::PORT5, vex::gearSetting::ratio18_1, false);
vex::motor      I(vex::PORT6, vex::gearSetting::ratio18_1, false);
vex::motor      P(vex::PORT7, vex::gearSetting::ratio36_1, true);
vex::controller con(vex::controllerType::primary);
vex::controller con_p(vex::controllerType::partner);
//#endregion config_globals

// Creates a competition object that allows access to Competition methods.
vex::competition Competition;

void pre_auton() {
    // All activities that occur before competition start
    // Example: setting initial positions

}

void autonomous() {
    // Place autonomous code here

}

void drivercontrol() {
    
    int fs = 70;
    int is = 70;
    int ps = 100;
    
    while (true) {
        Ld.spin(vex::directionType::fwd, con.Axis3.value(),vex::velocityUnits::pct);
        Ld2.spin(vex::directionType::fwd, con.Axis3.value(),vex::velocityUnits::pct);
        Rd.spin(vex::directionType::fwd, con.Axis2.value(), vex::velocityUnits::pct);
        Rd2.spin(vex::directionType::fwd, con.Axis2.value(), vex::velocityUnits::pct);
        
        if(con_p.ButtonR1.pressing()) {
            F.spin(directionType::fwd, fs, velocityUnits::pct);
        }
        else if(con_p.ButtonR2.pressing()) {
            F.spin(directionType::rev, fs, velocityUnits::pct);
        }
        else {
            F.stop(brakeType::coast);
        }
        if(con_p.ButtonL1.pressing()) {
            I.spin(directionType::fwd, is, velocityUnits::pct);
        }
        else if(con_p.ButtonL2.pressing()) {
            I.spin(directionType::rev, is, velocityUnits::pct);
        }
        else {
            I.stop(brakeType::coast);
        }
        if(con.ButtonA.pressing()) {
            P.spin(directionType::rev, ps, velocityUnits::pct);
        }
        else if(con.ButtonY.pressing()) {
            P.spin(directionType::fwd, ps, velocityUnits::pct);
        }
        else {
            P.stop(brakeType::coast);
        }
    }
}

int main() {
    // Do not adjust the lines below

    // Set up (but don't start) callbacks for autonomous and driver control periods.
    Competition.autonomous(autonomous);
    Competition.drivercontrol(drivercontrol);

    // Run the pre-autonomous function.
    pre_auton();

    // Robot Mesh Studio runtime continues to run until all threads and
    // competition callbacks are finished.
}

Your code looks like it should compile ok in Robot Mesh Studio V5 C++. What’s the error you’re receiving?

21:31:03 – error – In file included from cxx_entry.cpp:16:
./main.cpp:1:10: fatal error: ‘vex.h’ file not found
#include “vex.h”

and I already tried robot mesh, it compiles fine but doesn’t want to download onto the brain or run a mimic file

@oddshapedcoconut For future reference, see here:
How to format code

I assume you mean Vex Coding Studio

vex.h is not.a valid header file for VCS, usually the C++ source file would include robot-config.h

Yes, I meant the coding studio, and I’ll go give that a try

Ok, that fixed that issue, so thank you. However, it now has this error

22:07:07 – error – In file included from cxx_entry.cpp:16:
./main.cpp:6:17: error: redefinition of ‘Brain’
vex::brain Brain;
^
./robot-config.h:1:12: note: previous definition is here
vex::brain Brain;

delete the redefinition of Brain in main.cpp

Ok, I did that so now it’s just telling me I’m not connected to the brain (which I don’t have wit me) so I’ll have to test that tomorrow. Thanks for the help, and I’ll probably be back if I have any issues.