I'm trying to run the MPU6050 example software on my Raspberry Pi to test my gyroscope out and I keep running into the error that accelgyro is undefined. I'm fairly new to C++ so a lot of these errors are completely new to me.

I've already tried changing it from MPU6050::MPU6050 to just MPU6050 in the declaration for accelgyro but that threw a new error.

#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include "I2Cdev.h"
#include "MPU6050.h"

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

void setup() {
    // initialize device
    printf("Initializing I2C devices...\n");
    accelgyro.initialize();

    // verify connection
    printf("Testing device connections...\n");
    printf(accelgyro.testConnection() ? "MPU6050 connection successful\n" : "MPU6050 connection failed\n");
}

This was provided by the person who wrote the library, so I'd expected that this would build properly with this: sudo g++ -g -o demo_raw demo_raw.cpp -lwiringPi -lpthread -lm.

Edit 1: The other error I receive: /tmp/ccFp0Mah.o: In function `setup()': /home/pi/C-Library-Dual-MPU6050-DMP-for-Intel-Galileo-Edison/demo_raw.cpp:19: undefined reference to `MPU6050::initialize()' /home/pi/C-Library-Dual-MPU6050-DMP-for-Intel-Galileo-Edison/demo_raw.cpp:23: undefined reference to `MPU6050::testConnection()' /tmp/ccFp0Mah.o: In function `loop()': /home/pi/C-Library-Dual-MPU6050-DMP-for-Intel-Galileo-Edison/demo_raw.cpp:28: undefined reference to `MPU6050::getMotion6(short*, short*, short*, short*, short*, short*)' /tmp/ccFp0Mah.o: In function `__static_initialization_and_destruction_0(int, int)': /home/pi/C-Library-Dual-MPU6050-DMP-for-Intel-Galileo-Edison/demo_raw.cpp:11: undefined reference to `MPU6050::MPU6050()' collect2: error: ld returned 1 exit status

0 Answers