Open cherbin opened 4 years ago
I'm getting the folllowing errors
make gcc -g rpi-mpu6050.c -o rpi-mpu6050 rpi-mpu6050.c: In function ‘main’: rpi-mpu6050.c:46:20: warning: implicit declaration of function ‘i2c_smbus_read_byte_data’ [-Wimplicit-function-declaration] int8_t power = i2c_smbus_read_byte_data(fd, MPU_POWER1); ^~~~~~~~ rpi-mpu6050.c:47:5: warning: implicit declaration of function ‘i2c_smbus_write_byte_data’ [-Wimplicit-function-declaration] i2c_smbus_write_byte_data(fd, MPU_POWER1, ~(1 << 6) & power); ^~~~~~~~~ rpi-mpu6050.c:70:9: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration] sleep(1); ^~~~~ /usr/bin/ld: /tmp/ccKkAgbz.o: in function main': /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:46: undefined reference toi2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:47: undefined reference to i2c_smbus_write_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:50: undefined reference toi2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:51: undefined reference to i2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:53: undefined reference toi2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:54: undefined reference to i2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:55: undefined reference toi2c_smbus_read_byte_data' /usr/bin/ld: /tmp/ccKkAgbz.o:/opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:56: more undefined references to `i2c_smbus_read_byte_data' follow collect2: error: ld returned 1 exit status make: *** [Makefile:3: rpi-mpu6050] Error 1
main': /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:46: undefined reference to
i2c_smbus_write_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:50: undefined reference to
i2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:53: undefined reference to
i2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:55: undefined reference to
I know this is an old issue, but for future reference:
cc -o mpu rpi-mpu6050.c -li2c
The compile stage needs the i2c library.
I'm getting the folllowing errors
make gcc -g rpi-mpu6050.c -o rpi-mpu6050 rpi-mpu6050.c: In function ‘main’: rpi-mpu6050.c:46:20: warning: implicit declaration of function ‘i2c_smbus_read_byte_data’ [-Wimplicit-function-declaration] int8_t power = i2c_smbus_read_byte_data(fd, MPU_POWER1); ^
~~~~~~~ rpi-mpu6050.c:47:5: warning: implicit declaration of function ‘i2c_smbus_write_byte_data’ [-Wimplicit-function-declaration] i2c_smbus_write_byte_data(fd, MPU_POWER1, ~(1 << 6) & power); ^~~~~~~~~ rpi-mpu6050.c:70:9: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration] sleep(1); ^~~~~ /usr/bin/ld: /tmp/ccKkAgbz.o: in functionmain': /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:46: undefined reference to
i2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:47: undefined reference toi2c_smbus_write_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:50: undefined reference to
i2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:51: undefined reference toi2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:53: undefined reference to
i2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:54: undefined reference toi2c_smbus_read_byte_data' /usr/bin/ld: /opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:55: undefined reference to
i2c_smbus_read_byte_data' /usr/bin/ld: /tmp/ccKkAgbz.o:/opt/CANBUS/GYRO/C/rpi-mpu6050-master/rpi-mpu6050.c:56: more undefined references to `i2c_smbus_read_byte_data' follow collect2: error: ld returned 1 exit status make: *** [Makefile:3: rpi-mpu6050] Error 1