Hello forum, I followed a code created by team 2880E (Code) for Odometry/PID, and made my own similar version in the vexcode v5 program. I split the code into separate created files, same as 2880E. I have no problems in the problems terminal, and all of the logic and programming seems correct to me, but when I try and build or download the program, I get the following:
[info]: Saving Project ...
[info]: Project saved!
windows build for platform vexv5
"LINK build/Odometry.elf"
build/src/chassis-control.o: In function `drivePID()':
chassis-control.cpp:(.text._Z8drivePIDv+0xc): undefined reference to `yPosGlobal'
chassis-control.cpp:(.text._Z8drivePIDv+0x10): undefined reference to `yPosGlobal'
chassis-control.cpp:(.text._Z8drivePIDv+0x28): undefined reference to `xPosGlobal'
chassis-control.cpp:(.text._Z8drivePIDv+0x2c): undefined reference to `xPosGlobal'
build/src/chassis-control.o: In function `chassisControl()':
chassis-control.cpp:(.text._Z14chassisControlv+0x94): undefined reference to `xPosGlobal'
chassis-control.cpp:(.text._Z14chassisControlv+0x9c): undefined reference to `xPosGlobal'
chassis-control.cpp:(.text._Z14chassisControlv+0xa8): undefined reference to `yPosGlobal'
chassis-control.cpp:(.text._Z14chassisControlv+0xac): undefined reference to `yPosGlobal'
build/src/chassis-control.o: In function `_GLOBAL__sub_I_chassis_control.cpp':
chassis-control.cpp:(.text._GLOBAL__sub_I_chassis_control.cpp+0x0): undefined reference to `xPosGlobal'
chassis-control.cpp:(.text._GLOBAL__sub_I_chassis_control.cpp+0x8): undefined reference to `xPosGlobal'
chassis-control.cpp:(.text._GLOBAL__sub_I_chassis_control.cpp+0x14): undefined reference to `yPosGlobal'
chassis-control.cpp:(.text._GLOBAL__sub_I_chassis_control.cpp+0x18): undefined reference to `yPosGlobal'
build/src/main.o: In function `pre_auton()':
main.cpp:(.text._Z9pre_autonv+0x10): undefined reference to `Inertial6'
main.cpp:(.text._Z9pre_autonv+0x18): undefined reference to `Inertial6'
main.cpp:(.text._Z9pre_autonv+0x38): undefined reference to `Inertial6'
main.cpp:(.text._Z9pre_autonv+0x3c): undefined reference to `Inertial6'
main.cpp:(.text._Z9pre_autonv+0x5c): undefined reference to `Inertial6'
build/src/main.o:main.cpp:(.text._Z9pre_autonv+0x60): more undefined references to `Inertial6' follow
build/src/main.o: In function `autonomous()':
main.cpp:(.text._Z10autonomousv+0x24): undefined reference to `STrack'
main.cpp:(.text._Z10autonomousv+0x28): undefined reference to `STrack'
build/src/draw-field.o: In function `drawField()':
draw-field.cpp:(.text._Z9drawFieldv+0x2c0): undefined reference to `xPosGlobal'
draw-field.cpp:(.text._Z9drawFieldv+0x2c4): undefined reference to `yPosGlobal'
draw-field.cpp:(.text._Z9drawFieldv+0x2c8): undefined reference to `xPosGlobal'
draw-field.cpp:(.text._Z9drawFieldv+0x2cc): undefined reference to `yPosGlobal'
draw-field.cpp:(.text._Z9drawFieldv+0x50c): undefined reference to `xPosGlobal'
draw-field.cpp:(.text._Z9drawFieldv+0x514): undefined reference to `xPosGlobal'
draw-field.cpp:(.text._Z9drawFieldv+0x53c): undefined reference to `yPosGlobal'
draw-field.cpp:(.text._Z9drawFieldv+0x544): undefined reference to `yPosGlobal'
build/src/odometry.o: In function `positionTracking()':
odometry.cpp:(.text._Z16positionTrackingv+0xb0): undefined reference to `Inertial6'
odometry.cpp:(.text._Z16positionTrackingv+0xb8): undefined reference to `Inertial6'
odometry.cpp:(.text._Z16positionTrackingv+0x2b8): undefined reference to `xPosGlobal'
odometry.cpp:(.text._Z16positionTrackingv+0x2bc): undefined reference to `yPosGlobal'
odometry.cpp:(.text._Z16positionTrackingv+0x2c0): undefined reference to `xPosGlobal'
odometry.cpp:(.text._Z16positionTrackingv+0x2c4): undefined reference to `yPosGlobal'
odometry.cpp:(.text._Z16positionTrackingv+0x2fc): undefined reference to `Inertial6'
odometry.cpp:(.text._Z16positionTrackingv+0x304): undefined reference to `Inertial6'
make: *** [vex/mkrules.mk:18: build/Odometry.elf] Error 1
[error]: make process closed with exit code : 2
Here is my code. I had an error importing it to vexforum, so I put it all on a google doc (sorry ) with the name of the file in white at the top of each section.
I am not super concerned with the undefined references because I believe my include files are correct and they don’t seem to cause errors, though I am still not 100% sure why the program has the undefined references. I am not sure about the last 2 lines. The error says that I need to make process closed with exit code, and doesn’t reference where the error was. I went through and couldn’t find anywhere that had this error. I am not overly familiar with creating multiple files in C++ and including them between files, so I believe I most likely messed up somewhere along the way with one of the files including headers or something like that.
I was wondering if someone could look through my code and see if they see any include errors, or any problems of why my code wont compile. I am not worried about the odometry or code itself, I just want to get it running, then I can work on the odometry and edit the code. Thanks everyone in advance, and sorry if its confusing. Thanks again,
-Jack