-
Notifications
You must be signed in to change notification settings - Fork 6
/
cyber-ubuntu16.04-arm-compile
235 lines (163 loc) · 9.37 KB
/
cyber-ubuntu16.04-arm-compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
cmake version >= 3.12
sudo apt install libasio-dev libtinyxml2-dev
apt-get install libncurses5-dev
安装automake 工具, 用下面的命令安装好就可以了。
sudo apt-get install autoconf automake libtool
####compile protobuf
安装protobuffer:
https://github.com/protocolbuffers/protobuf/releases
下载 3.6.1版本
解压
./configure CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ --host=aarch64-linux-gnu --prefix=/protobuf-3.6.1
make -j8 && make check && sudo make install DESTDIR=/home/allen/aarch64-depends
####compile gflags
git clone https://github.com/gflags/gflags.git
cd gflags && mkdir build && cd build
export CROSS_COMPILE=aarch64-linux-gnu-
copy aarch64_toolchainfile.cmake to gflags directory and add below line to CMakeLists.txt:
include(../aarch64_toolchainfile.cmake)
cmake .. -DCMAKE_INSTALL_PREFIX=/gflags
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
####compile glog
git clone https://github.com/google/glog.git
cd glog
mkdir build && cd build
export CROSS_COMPILE=aarch64-linux-gnu-
copy aarch64_toolchainfile.cmake to gflags directory and add below line to CMakeLists.txt:
include(../aarch64_toolchainfile.cmake)
cmake .. -DCMAKE_INSTALL_PREFIX=/glog
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
####compile poco
git clone https://github.com/pocoproject/poco.git
cd poco
mkdir build && cd build
export CROSS_COMPILE=aarch64-linux-gnu-
copy aarch64_toolchainfile.cmake to gflags directory and add below line to CMakeLists.txt:
include(../aarch64_toolchainfile.cmake)
cmake .. -DCMAKE_INSTALL_PREFIX=/poco
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
####compile Foonathan memory
$ git clone https://github.com/eProsima/foonathan_memory_vendor.git
$ cd foonathan_memory_vendor
$ mkdir build && cd build
export CROSS_COMPILE=aarch64-linux-gnu-
copy aarch64_toolchainfile.cmake to gflags directory and add below line to CMakeLists.txt:
include(../aarch64_toolchainfile.cmake)
cmake .. -DCMAKE_INSTALL_PREFIX=/foonathan_memory_vendor
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
####compile Fast-CDR
https://github.com/eProsima/Fast-CDR/releases
下载 1.0.7版本
$ mkdir Fast-CDR/build && cd Fast-CDR/build
$ cmake ..
$ cmake --build . --target install
####compile Fast-RTPS
https://github.com/eProsima/Fast-RTPS/releases
下载1.5.0版本
$ mkdir Fast-RTPS/build && cd Fast-RTPS/build
$ cmake ..
$ cmake --build . --target install
编译可能遇到fastRTPS报错,std::function相关。。。打开对应文件#include <functional>
FastCDR与fastRTPS需要打patch才可以。patch文件:
https://github.com/ApolloAuto/apollo/issues/7240
也可以直接用该仓库中cyberRT-dependency目录中的三方库,其中fast-CDR和fast-RTPS已经打过补丁。
issue with compile fastRTPS, it depends on: fastcdr, asio(depend on boost), tinyxml2
fastcdr aarch64 version has been compiled.
so it needs to compile aarch64 version boost asio and tinyxml2.
#### compile boost
download boost_1.68.0;
unzip;
./bootstrap.sh
change project-config.jam:
if ! gcc in [ feature.values <toolset> ]
{
using gcc : arm : aarch64-linux-gnu-gcc ;
}
......
option.set prefix : /usr/bin ;
option.set exec-prefix : /usr/bin ;
option.set libdir : /usr/lib/aarch64-linux-gnu ;
option.set includedir : /usr/aarch64-linux-gnu/include ;
./bjam
./bjam install --prefix=/home/allen/aarch64-depends/boost
sudo cp -rf /home/allen/aarch64-depends/boost/* /usr/include/boost/
####compile asio
download asio-1.12.2
unzip
cd asio-1.12.2
./configure CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ --host=aarch64-linux-gnu --prefix=/asio
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
####compile tinyxml2
github download tinyxml2
copy aarch64_toolchainfile.cmake to tinyxml2 directory and add below line to CMakeLists.txt:
include(../aarch64_toolchainfile.cmake)
cmake .. -DCMAKE_INSTALL_PREFIX=/tinyxml2
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
compile fastrtps only need asio_include_dir
####compile Python2.7.12
https://www.python.org/ftp/python/2.7.12/
./configure CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ --host=aarch64-linux-gnu --prefix=/python2.7.12 --build=aarch64 --disable-ipv6 ac_cv_file__dev_ptmx="yes" ac_cv_file__dev_ptc="no"
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
####compile libuuid
https://sourceforge.net/projects/libuuid/
./configure CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ --host=aarch64-linux-gnu --prefix=/uuid
make -j8 && sudo make install DESTDIR=~/aarch64-depends/
####compile ncurses5.9
http://ftp.gnu.org/pub/gnu/ncurses/
./configure CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ --host=arm-linux --with-shared --prefix=/ncurses-5.9
compile error resolve:
cd ncurses/include
sudo vim curses.tail
find mouse_trafo in line 104, delete the comment of this line.
make -j8 && sudo make install DESTDIR=/home/allen/aarch64-depends
###############
./configure --help can show how to use ./configure command
protobuf3.5.1 protobuf 3.6.1编译ubuntu16.04.3 aarch64版本天坑:(cyber需要移植到ascend310平台,cyber依赖于protobuf,所以需要先交叉编译出来aarch64版本的protobuf):
1。去https://github.com/protocolbuffers/protobuf/releases下载对应版本(protobuf-all-3.6.1.tar.gz或者protobuf-all-3.5.1.tar.gz)
2。 解压后将protobuf-3.6.1目录复制一份命名:protobuf-3.6.1-x86
3。一定要先编译x86版本的protobuf:cd protobuf-3.6.1-x86/cmake && mkdir build && cd build && cmake .. && make -j8
应该可以很顺利的编译出x86版本。
4。cd protobuf-3.6.1/cmake 然后复制aarch64_toolchainfile.cmake到cmake目录,将下面语句添加到CMakeLists.txt的projiect(...)语句下面。
include(./aarch64_toolchainfile.cmake)
5。mkdir build && cd build && cmake .. && make -j8
这一步编译的时候肯定会出问题,因为编译的后半段会用到编译的前半段编译出的一个二进制文件(js_embed)来执行,但是二进制文件是aarch64版本,肯定无法执行!所以此时就要将protobuf-3.6.1-x86/cmake/build/下面的这个二进制文件复制到protobuf-3.6.1/cmake/build下面,接着继续编译。然后就成功了。
6。然后sudo make install DESTDIR=/home/allen/aarch64-depends
会在/home/allen/aarch64-depends下面创建目录usr/local/{bin和include和lib}。lib/cmake/protobuf下面就包含了.cmake文件。
cd /home/allen/aarch64-depends && mkdir protobuf-3.6.1 然后将上面/home/allen/aarch64-depends下面创建目录usr/local/下面的内容都复制到
/home/allen/aarch64-depends/protobuf-3.6.1。
7。然后编译cyber的时候:
cd cyber-ubuntu16.04-aarch64/cmake
vim Dependdencies.cmake 修改:
set(Protobuf_ROOT /home/allen/aarch64-depends/protobuf-3.6.1/lib/cmake/protobuf)
set(Protobuf_DIR /home/allen/aarch64-depends/protobuf-3.6.1/lib/cmake/protobuf)
find_package(Protobuf REQUIRED CONFIG)
message(STATUS "version: ${Protobuf_VERSION}")
message(STATUS "###Found Protobuf: ${Protobuf_INCLUDE_DIRS} ${Protobuf_LIBRARIES}")
include_directories(${PROTOBUF_INCLUDE_DIRS})
link_directories(${PROTOBUF_LIBRARIES})
8. cd /home/allen/cyber-ubuntu16.04-aarch64/build && cmake .. && make -j8
然后报错:Unknown CMake command "PROTOBUF_GENERATE_CPP"
同时###Found Protobuf: ${Protobuf_INCLUDE_DIRS} ${Protobuf_LIBRARIES} 也无法打印出来这2个变量。
此时需要修改:
cd /home/allen/aarch64-depends/protobuf-3.6.1/lib/cmake/protobuf
vim protobuf-config.cmake
#if ( protobuf_MODULE_COMPATIABLE)
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-module.cmake")
#endif()
9。 继续编译还是会报错:
/home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: 2: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: 2: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: 2: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: 2: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: 2: /home/allen/aarch64-depends/protobuf-3.5.1/bin/protoc: Syntax error: ")" unexpected
cyber/proto/CMakeFiles/cyber_proto.dir/build.make:75: recipe for target 'cyber/proto/component_conf.pb.h' failed
make[2]: *** [cyber/proto/component_conf.pb.h] Error 2
make[2]: *** Waiting for unfinished jobs....
Syntax error: ")" unexpected
cyber/proto/CMakeFiles/cyber_proto.dir/build.make:82: recipe for target 'cyber/proto/cyber_conf.pb.h' failed
make[2]: *** [cyber/proto/cyber_conf.pb.h] Error 2
Syntax error: ")" unexpected
cyber/examples/proto/CMakeFiles/cyber_example_proto.dir/build.make:61: recipe for target 'cyber/examples/proto/examples.pb.h' failed
make[2]: *** [cyber/examples/proto/examples.pb.h] Error 2
CMakeFiles/Makefile2:3025: recipe for target 'cyber/examples/proto/CMakeFiles/cyber_example_proto.dir/all' failed
原因:编译cyber的过程中需要用protoc文件来生成xx.pb.h文件,但是引用的确实aarch64版本的protoc。
解决办法:cd /home/allen/aarch64-depends/protobuf-3.6.1/bin && mv protoc protoc-arm
然后将x86版本的protoc复制到该目录中:
cp /home/allen/protobuf-3.6.1-x86/cmake/build/protoc /home/allen/aarch64-depends/protobuf-3.6.1/bin
然后 继续编译大功告成!!!!