File tree 3 files changed +34
-24
lines changed
3 files changed +34
-24
lines changed Original file line number Diff line number Diff line change 2
2
// Copyright (c) 2019, Alex Mous
3
3
// Licensed under the CC BY-NC SA 4.0
4
4
5
- // Includes
6
- #include < iostream>
7
- #include < unistd.h>
8
- #include < fcntl.h>
9
- #include < sys/ioctl.h>
10
- #include < sys/types.h>
11
- #include < time.h>
12
- #include < linux/i2c-dev.h>
13
- #include < cmath>
14
- #include < thread>
15
-
16
5
// Include the header file for this class
17
6
#include " MPU6050.h"
18
7
Original file line number Diff line number Diff line change 41
41
#include < sys/ioctl.h>
42
42
#include < sys/types.h>
43
43
#include < time.h>
44
- #include < linux/i2c-dev.h>
45
- #include < i2c/smbus.h>
44
+ extern " C" {
45
+ #include < linux/i2c-dev.h>
46
+ #include < i2c/smbus.h>
47
+ }
46
48
#include < cmath>
47
49
#include < thread>
48
50
Original file line number Diff line number Diff line change 1
- all : MPU6050.cpp
2
- g++ -fPIC -c MPU6050.cpp -o MPU6050.o
3
- g++ -shared -o libMPU6050.so MPU6050.o
4
- install -m 755 -p libMPU6050.so /usr/lib/
5
- install -m 644 -p MPU6050.h /usr/include/
6
- rm -f MPU6050.o
7
- rm -f libMPU6050.so
1
+ CC =g++
8
2
9
- clean :
3
+ DEPS =MPU6050.h
4
+ CFLAGS =-fPIC -Wall
5
+
6
+ LIBS =-li2c
7
+ LFLAGS =-shared
8
+
9
+ OBJ =MPU6050.o
10
+ OLIB =libMPU6050.so
11
+
12
+
13
+
14
+ % .o : % .cpp $(DEPS )
15
+ $(CC ) -c $< -o $@ $(CFLAGS )
16
+
17
+ all : $(OBJ )
18
+ $(CC ) -o $(OLIB ) $< $(LIBS ) $(LFLAGS )
19
+
20
+ install : all $(OLIB ) $(DEPS )
21
+ install -m 755 -p $(OLIB ) /usr/lib/
22
+ install -m 644 -p $(DEPS ) /usr/include/
23
+
24
+ uninstall :
10
25
rm -f /usr/include/MPU6050.h
11
26
rm -f /usr/lib/libMPU6050.so
27
+
28
+ clean :
12
29
rm -f Example
30
+ rm -f Example.o
31
+ rm -f MPU6050.o
32
+ rm -f libMPU6050.so
13
33
14
- example :
15
- g++ Example.cpp -o Example -lMPU6050 -pthread
16
- ./Example
34
+ example : Example.o
35
+ $(CC ) $< -o Example -lMPU6050 -pthread
You can’t perform that action at this time.
0 commit comments