# Setting up a Development Environment - [Environment Requirements](#section179175261196) - [Hardware](#section185788208272) - [Software](#section3343841379) - [Build Tools for Linux](#section20374218687) - [Development Tools for Windows](#section11161833102716) - [Installing the Basic Compilation Environment](#section497484245614) - [Connecting to a Linux Server](#section73731485127) - [Changing Linux Shell to Bash](#section11741048173311) - [Installing a Python Environment](#section16270312203916) - [Installing a File Packing Tool](#section755831544314) - [Installing Compilation Tools](#section7227629152013) - [Installing gn](#section1737610811213) - [Installing ninjah](#section103777819124) - [Installing the LLVM Toolchain](#section11613193644213) - [Installing hc-gen](#section139624410163) - [Installing the JVM](#section1413015314289) - [Installing the HAP Packing Tool](#section137261201916) - [Installing the HAP Signature Tool](#section6880458114617) - [Installing the IDE Development Tool](#section1995840162515) ## Environment Requirements ## Hardware - Linux server - Windows workstation \(host computer\) - Hi3516DV300 IoT camera development board - USB-to-serial cable and network cable \(The Windows workstation is connected to Hi3516DV300 development board through the USB-to-serial cable and network cable.\) [Figure 1](#fa54d47112b684c65b3dbf1779413545a) shows the hardware connections. **Figure 1** Hardware connections ![](figures/矩形备份-292.png) ## Software **Table 1** Platforms required for the Hi3516DV300 development board

Hardware

Software

Description

Remarks

Linux compile server

Operating system

Ubuntu 16.04 64-bit or later is used for the Linux OS, and bash is used as the shell.

NOTE:

Common software such as samba and vim is installed in the OS by default. Adaptation is required to support Linux file sharing.

You can develop programs on the Windows workstation or on the Linux server through remote login.

Windows workstation

Operating system

Windows XP/Windows7/Windows10

USB-to-Serial adapter driver

http://www.hihope.org/download/AllDocuments

Driver name: USB-to-Serial Comm Port.exe

## Build Tools for Linux The following table describes the common tools required for Linux and how to obtain them. **Table 2** Development tools and obtaining methods

Development Tool

Description

How to Obtain

Python3.7+

Runs the compilation scripts.

https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

bash

Executes commands.

Internet

gn

Generates ninja compilation scripts.

https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar

ninja

Executes ninja compilation scripts.

https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar

LLVM

Functions as the compiler toolchain.

https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar

hc-gen

Configures and compiles files.

https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar

IPOP, PuTTY, or other HyperTerminal software

Connects to the Linux server (choose one of the terminals).

Internet (for example, https://www.putty.org/)

Java virtual machine (JVM)

Compiles, debugs, and runs Java programs.

apt-get install

hmos_app_packing_tool

HAP packing tool

https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar

hapsigntool

HAP signature tool

https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar

## Development Tools for Windows **Table 3** Development tools for the Windows workstation

Development Tool

Description

How to Obtain

Visual Studio Code

Edits codes.

https://code.visualstudio.com/

HUAWEI DevEco Device Tool

Functions as the integrated development environment (IDE) to provide code compilation, burning, and debugging. C and C++ languages are supported.

NOTE:

HUAWEI DevEco Device Tool is a one-stop IDE provided by OpenHarmony for smart device developers. You can customize OpenHarmony components on it as required, HUAWEI DevEco Device Tool is deployed on Visual Studio Code as a plug-in.

https://device.harmonyos.com/en/ide

## Installing the Basic Compilation Environment ## Connecting to a Linux Server Using PuTTY to log in to a Linux server from a PC running Windows 1. Open [PuTTY](https://www.putty.org/), enter the IP address of the Linux server, and click **Open**. **Figure 2** PuTTY configuration ![](figures/putty-configuration.png "putty-configuration") 2. Click **Yes** in the PuTTY **Security Alert** dialog box. 3. Enter the account and password. **Figure 3** Login ![](figures/login.png "login") 4. The login is successful. **Figure 4** Successful login ![](figures/successful-login.png "successful-login") ## Changing Linux Shell to Bash Run the following command to check whether bash is used as the shell: ``` ls -l /bin/sh ``` If **/bin/sh -\> bash** is not displayed, do as follows to change shell to bash. **Method 1:** Run the following command on the device and then click **No**. ``` sudo dpkg-reconfigure dash ``` **Method 2:** Run the **rm -rf /bin/sh** command to delete sh and then run the sudo **ln -s /bin/bash /bin/sh** command to create a new soft link. ``` sudo rm -rf /bin/sh sudo ln -s /bin/bash /bin/sh ``` ## Installing a Python Environment 1. Start a Linux server. 2. Run the following command to check the Python version \(Python 3.7 or later is required\): ``` python3 --version ``` Do as follows to install Python, for example, Python 3.8. 1. Run the following command to check the Ubuntu version: ``` cat /etc/issue ``` 1. Install Python based on the Ubuntu version. - If the Ubuntu version is 18 or later, run the following command: ``` sudo apt-get install python3.8 ``` - If the Ubuntu version is 16, download the installation package and install Python. 1. Run the following command to install Python environment dependencies \(gcc, g++, make, zlib, libffi\): ``` sudo apt-get install gcc && sudo apt-get install g++ && sudo apt-get install make && sudo apt-get install zlib* && sudo apt-get install libffi-dev ``` 1. Obtain the [Python3.8.5 installation package](https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz), save it to the Linux server, and run the following command: ``` tar -xvzf Python-3.8.5.tgz && cd Python-3.8.5 && sudo ./configure && sudo make && sudo make install ``` 3. After Python is installed, link the Python path to **/usr/bin/python**: Run the following command to check whether Python is soft linked to Python3: ``` python --version ``` If the command output is not **python 3.8.5**, run the following command to check the directory where Python3.8 is stored: ``` which python3.8 ``` Replace **python3.8-path** in the following command with the output path of the **which python3.8** command. ``` cd /usr/bin && sudo rm python && sudo ln -s python3.8-path python && python --version ``` 4. Install and upgrade the Python package management tool \(pip3\) using either of the following methods: - **Command line:** ``` sudo apt-get install python3-setuptools python3-pip -y sudo pip3 install --upgrade pip ``` - **Installation package:** ``` curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py ``` 5. Run the following command to install setuptools: ``` pip3 install setuptools ``` 6. Install the GUI menuconfig tool \(Kconfiglib\). You are advised to install Kconfiglib 13.2.0 or later. - **Command line:** ``` sudo pip3 install kconfiglib ``` - **Installation package:** 1. Download the .whl file \(for example, **kconfiglib-13.2.0-py2.py3-none-any.whl**\). Download path: [https://pypi.org/project/kconfiglib\#files](https://pypi.org/project/kconfiglib#files) 1. Run the following command to install the .whl file: ``` sudo pip3 install kconfiglib-13.2.0-py2.py3-none-any.whl ``` ## Installing a File Packing Tool 1. Start a Linux server. 2. Run the following command to install **dosfstools**: ``` sudo apt-get install dosfstools ``` 3. Run the following command to install **mtools**: ``` sudo apt-get install mtools ``` 4. Run the following command to install **mtd-utils**: ``` sudo apt-get install mtd-utils ``` ## Installing Compilation Tools >![](public_sys-resources/icon-notice.gif) **NOTICE:** >- If you obtain the source code using an HPM component or HPM CLI tool, compilation tools like **gn**, **ninja**, **LLVM**, and **hc-gen** are not required. >- \(Recommended\) If you obtain the source code through an image site or a code repository, compilation tools like **gn**, **ninja**, **LLVM**, and **hc-gen** need to be installed. > When installing **gn**, **ninja**, **LLVM**, and **hc-gen**, ensure that the environment variable paths of the compilation tools are unique. ## Installing gn 1. Start a Linux server. 2. Download [gn](https://repo.huaweicloud.com/harmonyos/compiler/gn/1523/linux/gn.1523.tar). 3. Run the following command to decompress the gn installation package to **\~/gn**. ``` tar -xvf gn.1523.tar -C ~/ ``` 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/gn:$PATH ``` 5. Run the following command to validate the environment variable. ``` source ~/.bashrc ``` ## Installing ninjah 1. Start a Linux server. 2. Download [ninja](https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar). 3. Run the following command to decompress the ninja installation package to **\~/ninja**. ``` tar -xvf ninja.1.9.0.tar -C ~/ ``` 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/ninja:$PATH ``` 5. Run the following command to validate the environment variable. ``` source ~/.bashrc ``` ## Installing the LLVM Toolchain 1. Start a Linux server. 2. Download [LLVM](http://tools.harmonyos.com/mirrors/clang/9.0.0-34042/linux/llvm-linux-9.0.0-34042.tar). 3. Run the following command to decompress the LLVM installation package to **\~/llvm**: ``` tar -xvf llvm-linux-9.0.0-34042.tar -C ~/ ``` 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/llvm/bin:$PATH ``` 5. Run the following command to validate the environment variable: ``` source ~/.bashrc ``` ## Installing hc-gen 1. Start a Linux server. 2. Download [hc-gen](https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar). 3. Run the following command to decompress the hc-gen installation package to **\~/hc-gen** on the Linux server: ``` tar -xvf hc-gen-0.65-linux.tar -C ~/ ``` 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/hc-gen:$PATH ``` 5. Run the following command to validate the environment variable: ``` source ~/.bashrc ``` ## Installing the JVM 1. Start a Linux server. 2. Run the following command to install the Java Runtime Environment \(JRE\): ``` sudo apt-get install default-jre ``` 3. Run the following command to install the Java Development Kit \(JDK\): ``` sudo apt-get install default-jdk ``` ## Installing the HAP Packing Tool The HAP packing tool is used for packaging system applications during the compilation of OpenHarmony. To install this tool, perform the following operations: 1. Start a Linux server. 2. Install the JVM before using the HAP packing tool. 3. [Download the HAP packing tool](https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar). 4. Copy **hmos\_app\_packing\_tool.jar** to the **\~/developtools** directory on the Linux server. 5. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/developtools:$PATH ``` 6. Run the following command to validate the environment variable: ``` source ~/.bashrc ``` ## Installing the HAP Signature Tool The HAP signature tool is used for signing system applications that have been packaged during the compilation of OpenHarmony. To install this tool, perform the following operations: 1. Start a Linux server. 2. [Download the HAP signature tool](https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar). 3. Copy **hapsigntoolv2.jar** to the **\~/developtools** directory on the Linux server. 4. Set an environment variable by performing the following steps. Open the **\~/.bashrc** file in Vim first. ``` vim ~/.bashrc ``` Copy the following command to the last line of the **.bashrc** file, save the file, and exit. ``` export PATH=~/developtools:$PATH ``` 5. Run the following command to validate the environment variable: ``` source ~/.bashrc ``` ## Installing the IDE Development Tool The OpenHarmony IDE Development Tool \(HUAWEI DevEco Device Tool\) integrates the capabilities of terminal tools. For details about how to install the tool, see [Preparations ](https://device.harmonyos.com/en/docs/ide/user-guides/tool_install-0000001050164976)and [Importing and Configuring a Project](https://device.harmonyos.com/en/docs/ide/user-guides/import_project-0000001050164980).