faqs-building.md 5.1 KB
Newer Older
1
# Compilation and Building
W
wusongqing 已提交
2 3


E
ester.zhou 已提交
4
## Mini and Small Systems
W
wusongqing 已提交
5 6


E
ester.zhou 已提交
7
### "usr/sbin/ninja: invalid option -- w" Displayed During the Build Process
W
wusongqing 已提交
8

E
ester.zhou 已提交
9
- **Symptom**
W
wusongqing 已提交
10
  
A
Annie_wang 已提交
11 12 13

  The compilation fails, and **usr/sbin/ninja: invalid option -- w** is displayed.

E
ester.zhou 已提交
14
- **Possible Causes**
A
Annie_wang 已提交
15 16 17

  The Ninja version in the compilation environment is outdated and does not support the --w option.

E
ester.zhou 已提交
18
- **Solution**
W
wusongqing 已提交
19
  
E
ester.zhou 已提交
20
  Uninstall Ninja and GN in the environment and reinstall them by following instructions in [Obtaining Tools](../get-code/gettools-ide.md).
W
wusongqing 已提交
21 22


E
ester.zhou 已提交
23
### "/usr/bin/ld: cannot find -lncurses" Displayed During the Build Process
W
wusongqing 已提交
24

E
ester.zhou 已提交
25
- **Symptom**
W
wusongqing 已提交
26
  
A
Annie_wang 已提交
27 28 29

  The compilation fails, and **/usr/bin/ld: cannot find -lncurses** is displayed.

E
ester.zhou 已提交
30
- **Possible Causes**
W
wusongqing 已提交
31
  
A
Annie_wang 已提交
32 33 34

  The ncurses library is not installed.

E
ester.zhou 已提交
35
- **Solution**
W
wusongqing 已提交
36
  
E
ester.zhou 已提交
37
  ```
A
Annie_wang 已提交
38
  sudo apt-get install lib32ncurses5-dev
E
ester.zhou 已提交
39
  ```
W
wusongqing 已提交
40 41


E
ester.zhou 已提交
42
### "line 77: mcopy: command not found" Displayed During the Build Process
W
wusongqing 已提交
43

E
ester.zhou 已提交
44
- **Symptom**
W
wusongqing 已提交
45
  
A
Annie_wang 已提交
46 47 48

  The compilation fails, and **line 77: mcopy: command not found** is displayed.

E
ester.zhou 已提交
49
- **Possible Causes**
W
wusongqing 已提交
50
  
A
Annie_wang 已提交
51 52 53

  Mcopy is not installed.

E
ester.zhou 已提交
54
- **Solution**
W
wusongqing 已提交
55
  
E
ester.zhou 已提交
56
  ```
A
Annie_wang 已提交
57
  sudo apt-get install dosfstools mtools
E
ester.zhou 已提交
58
  ```
W
wusongqing 已提交
59 60


E
ester.zhou 已提交
61
### "riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory" Displayed During the Build Process
W
wusongqing 已提交
62

E
ester.zhou 已提交
63
- **Symptom**
W
wusongqing 已提交
64
  
A
Annie_wang 已提交
65 66 67

  The compilation fails, and the following information is displayed: **riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory**.

E
ester.zhou 已提交
68
- **Possible Causes**
W
wusongqing 已提交
69
  
A
Annie_wang 已提交
70 71 72

  Permission is required to access files in the **riscv** compiler path.

E
ester.zhou 已提交
73
- **Solution**
A
Annie_wang 已提交
74 75 76
  
  1. Run the following command to query the directory where **gcc_riscv32** is located:
  
W
wusongqing 已提交
77
  
E
ester.zhou 已提交
78 79
  ```
  which riscv32-unknown-elf-gcc
A
Annie_wang 已提交
80
  ```
W
wusongqing 已提交
81
  
A
Annie_wang 已提交
82
  2. Run the **chmod** command to change the directory permission to **755**.
W
wusongqing 已提交
83 84


E
ester.zhou 已提交
85
### "No module named 'Crypto'" Displayed During the Build Process
W
wusongqing 已提交
86

E
ester.zhou 已提交
87
- **Symptom**
W
wusongqing 已提交
88
  
A
Annie_wang 已提交
89
  The compilation fails, and **No module named'Crypto loaded** is displayed.
W
wusongqing 已提交
90
  
E
ester.zhou 已提交
91
- **Possible Causes**
W
wusongqing 已提交
92
  
A
Annie_wang 已提交
93
  Crypto is not installed in Python3.
A
Annie_wang 已提交
94

E
ester.zhou 已提交
95
- **Solution**
A
Annie_wang 已提交
96 97 98

  1. Run the following command to query the Python version:
        
A
Annie_wang 已提交
99
      ```
E
ester.zhou 已提交
100
      python3 --version
A
Annie_wang 已提交
101
      ```
E
ester.zhou 已提交
102
  2. Ensure that Python 3.7 or later is installed, and then run the following command to install pycryptodome:
A
Annie_wang 已提交
103
        
E
ester.zhou 已提交
104 105
      ```
      sudo pip3 install pycryptodome
A
Annie_wang 已提交
106 107
      ```

W
wusongqing 已提交
108

E
ester.zhou 已提交
109
### "xx.sh : xx unexpected operator" Displayed During the Build Process
W
wusongqing 已提交
110

E
ester.zhou 已提交
111
- **Symptom**
W
wusongqing 已提交
112
  
A
Annie_wang 已提交
113 114 115

  The compilation fails, and **xx.sh [: xx unexpected operator** is displayed.

E
ester.zhou 已提交
116
- **Possible Causes**
W
wusongqing 已提交
117
  
A
Annie_wang 已提交
118 119 120

  The compilation environment is shell instead of bash.

E
ester.zhou 已提交
121
- **Solution**
W
wusongqing 已提交
122
  
E
ester.zhou 已提交
123 124 125 126
  ```
  sudo rm -rf /bin/sh
  sudo ln -s /bin/bash /bin/sh
  ```
W
wusongqing 已提交
127 128


E
ester.zhou 已提交
129
### "Could not find a version that satisfies the requirement six>=1.9.0" Displayed During the Build Process
W
wusongqing 已提交
130

E
ester.zhou 已提交
131
- **Symptom**
W
wusongqing 已提交
132
  
A
Annie_wang 已提交
133 134 135 136

  The following error occurs during compilation and building:


E
ester.zhou 已提交
137 138
  ```
  Could not find a version that satisfies the requirement six>=1.9.0
A
Annie_wang 已提交
139 140
  ```

E
ester.zhou 已提交
141
- **Possible Causes**
W
wusongqing 已提交
142
  
A
Annie_wang 已提交
143 144 145

  **six** is not installed.

E
ester.zhou 已提交
146
- **Solution**
A
Annie_wang 已提交
147

A
Annie_wang 已提交
148
  Method 1: Run the **pip3 install six** command to install **six** online.
A
Annie_wang 已提交
149

A
Annie_wang 已提交
150
  Method 2: Install **six** offline.
A
Annie_wang 已提交
151 152 153 154 155 156 157 158

  Download the installation package from [PyPI](https://pypi.org/project/six/#files).

  ![en-us_image_0000001251276115](figures/en-us_image_0000001251276115.png)

  Save the source code to the Linux server and run the **pip3 install six-1.14.0-py2.py3-none-any.whl** command to install **six**.

After the preceding installation is complete, rebuild an environment.
W
wusongqing 已提交
159 160


E
ester.zhou 已提交
161
### "cannot find -lgcc" Displayed During the Build Process
W
wusongqing 已提交
162

E
ester.zhou 已提交
163
- **Symptom**
W
wusongqing 已提交
164
  
A
Annie_wang 已提交
165 166 167 168

  The following error occurs during the build process:


E
ester.zhou 已提交
169 170
  ```
  riscv32-unknown-elf-ld: cannot find -lgcc
A
Annie_wang 已提交
171 172
  ```

E
ester.zhou 已提交
173
- **Possible Causes**
W
wusongqing 已提交
174
  
A
Annie_wang 已提交
175 176 177 178

  The gcc_riscv32 PATH is incorrect. There is an extra slash (/) after **bin**.


E
ester.zhou 已提交
179 180
  ```
  ~/gcc_riscv32/bin/:/data/toolchain/
A
Annie_wang 已提交
181 182
  ```

E
ester.zhou 已提交
183
- **Solution**
W
wusongqing 已提交
184
  
A
Annie_wang 已提交
185 186 187 188

  Modify the PATH as follows:


E
ester.zhou 已提交
189 190 191
  ```
  ~/gcc_riscv32/bin:/data/toolchain/
  ```
W
wusongqing 已提交
192 193


E
ester.zhou 已提交
194
### The Message Indicating Python Cannot Be Found Is Displayed During the Build Process
W
wusongqing 已提交
195

E
ester.zhou 已提交
196
- **Symptom**
W
wusongqing 已提交
197
  
A
Annie_wang 已提交
198 199 200 201

  The following error occurs during the build process:


E
ester.zhou 已提交
202 203
  ```
  -bash: /usr/bin/python: No such file or directory
A
Annie_wang 已提交
204 205
  ```

E
ester.zhou 已提交
206
- **Possible Cause 1**
W
wusongqing 已提交
207
  
A
Annie_wang 已提交
208 209 210

  Python is not installed.

E
ester.zhou 已提交
211
- **Solution**
W
wusongqing 已提交
212
  
A
Annie_wang 已提交
213 214 215 216

  Run the following command to install Python (Python 3.8 for example):


E
ester.zhou 已提交
217 218
  ```
  sudo apt-get install python3.8
A
Annie_wang 已提交
219 220
  ```

E
ester.zhou 已提交
221
- **Possible Cause 2**
W
wusongqing 已提交
222
  
A
Annie_wang 已提交
223 224 225 226 227

  The soft link that points to the Python does not exist in the **usr/bin** directory.

  ![en-us_image_0000001243200677](figures/en-us_image_0000001243200677.png)

E
ester.zhou 已提交
228
- **Solution**
W
wusongqing 已提交
229
  
A
Annie_wang 已提交
230 231 232 233

  Run the following commands to add a soft link:


E
ester.zhou 已提交
234 235 236 237 238
  ```
  # cd /usr/bin/ 
  # which python3
  # ln -s /usr/local/bin/python3 python
  # python --version
A
Annie_wang 已提交
239 240
  ```

W
wusongqing 已提交
241
Example:
A
Annie_wang 已提交
242

E
ester.zhou 已提交
243
  ![en-us_image_0000001243320787](figures/en-us_image_0000001243320787.png)
W
wusongqing 已提交
244 245


E
ester.zhou 已提交
246
### The Message Indicating Python 3 Cannot Be Found Is Displayed During the Build Process
W
wusongqing 已提交
247

E
ester.zhou 已提交
248
- **Symptom**
W
wusongqing 已提交
249

E
ester.zhou 已提交
250
  ![en-us_image_0000001251276255](figures/en-us_image_0000001251276255.png)
W
wusongqing 已提交
251

E
ester.zhou 已提交
252
- **Possible Causes**
W
wusongqing 已提交
253
  
A
Annie_wang 已提交
254 255 256

  Python 3 is not installed.

E
ester.zhou 已提交
257
- **Solution**
W
wusongqing 已提交
258
  
A
Annie_wang 已提交
259 260 261 262

  Run the following command to install Python 3:


E
ester.zhou 已提交
263 264 265
  ```
  sudo apt-get install python3.8
  ```