im new to programming, so this may sound dumb. I got these messages, and got no idea how to fix it. (program is in C btw)

#include <wiringPiI2C.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define DevAddr 0x53 //device address
struct acc_dat{
int x;
int y;
int z;
void adxl345_init(int fd)
wiringPiI2CWriteReg8(fd, 0x31, 0x0b);
wiringPiI2CWriteReg8(fd, 0x2d, 0x08);
// wiringPiI2CWriteReg8(fd, 0x2e, 0x00);
wiringPiI2CWriteReg8(fd, 0x1e, 0x00);
wiringPiI2CWriteReg8(fd, 0x1f, 0x00);
wiringPiI2CWriteReg8(fd, 0x20, 0x00);

wiringPiI2CWriteReg8(fd, 0x21, 0x00);
wiringPiI2CWriteReg8(fd, 0x22, 0x00);
wiringPiI2CWriteReg8(fd, 0x23, 0x00);
wiringPiI2CWriteReg8(fd, 0x24, 0x01);
wiringPiI2CWriteReg8(fd, 0x25, 0x0f);
wiringPiI2CWriteReg8(fd, 0x26, 0x2b);
wiringPiI2CWriteReg8(fd, 0x27, 0x00);

wiringPiI2CWriteReg8(fd, 0x28, 0x09);
wiringPiI2CWriteReg8(fd, 0x29, 0xff);
wiringPiI2CWriteReg8(fd, 0x2a, 0x80);
wiringPiI2CWriteReg8(fd, 0x2c, 0x0a);
wiringPiI2CWriteReg8(fd, 0x2f, 0x00);
wiringPiI2CWriteReg8(fd, 0x38, 0x9f);
struct acc_dat adxl345_read_xyz(int fd)
char x0, y0, z0, x1, y1, z1;
struct acc_dat acc_xyz;
x0 = 0xff - wiringPiI2CReadReg8(fd, 0x32);
x1 = 0xff - wiringPiI2CReadReg8(fd, 0x33);
y0 = 0xff - wiringPiI2CReadReg8(fd, 0x34);
y1 = 0xff - wiringPiI2CReadReg8(fd, 0x35);
z0 = 0xff - wiringPiI2CReadReg8(fd, 0x36);
z1 = 0xff - wiringPiI2CReadReg8(fd, 0x37);
acc_xyz.x = (int)(x1 << 8) + (int)x0;
acc_xyz.y = (int)(y1 << 8) + (int)y0;
acc_xyz.z = (int)(z1 << 8) + (int)z0;
return acc_xyz;
int main(void)
int fd;
struct acc_dat acc_xyz;
fd = wiringPiI2CSetup(DevAddr);

if(-1 == fd){
perror("I2C device setup error"); 
acc_xyz = adxl345_read_xyz(fd);
printf("x: %05d y: %05d z: %05d\n", acc_xyz.x, acc_xyz.y, acc_xyz.z);


return 0;

//error messages- Arduino: 1.6.10 Hourly Build 2016/06/06 09:13 (Mac OS X), Board: “Arduino/Genuino Uno”

/Users/ahmarabbas/Documents/Arduino/sketch_jun29c/sketch_jun29c.ino:1:25: fatal error: wiringPiI2C.h: No such file or directory
#include <wiringPiI2C.h>
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

are you sure your board is an Arduino/Genuino Uno?

have you imported the right library? (isn't that a Raspberry Pi library?)

It is the right board for sure. And the thing is, i don't know how to get the library. It it possible to import the library of raspberry despite having an arduino board?


looking at the code above it seems you want to drive an ADXL345 (low power, 3-axis accelerometer with high resolution)

the code you have just reads xyz and prints them. so you need to get library or code for Arduino - there are many sources on the web for this, like this one