“ MPU6050 :: MPU6050”命名构造函数,而不是类型

时间:2019-04-22 22:15:16

标签: c++ raspberry-pi mpu6050

我正在尝试在Raspberry Pi上运行MPU6050示例软件来测试陀螺仪,但我一直遇到未定义accelgyro的错误。我是C ++的新手,所以其中许多错误对我来说都是全新的。

我已经尝试在accelgyro的声明中将其从MPU6050 :: MPU6050更改为仅MPU6050,但这引发了新的错误。

#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");
}

这是由编写该库的人提供的,因此,我希望它可以与此一起正确构建:sudo g ++ -g -o demo_raw demo_raw.cpp -lwiringPi -lpthread -lm。

编辑1:我收到的另一个错误:/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 个答案:

没有答案