1e41f4b71Sopenharmony_ci# Writing a Hello World Program 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciThe following exemplifies how to run the first program on the development board. The created program outputs the message "Hello World!" 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci## Prerequisites 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciA project for the Hi3516 development board has been created as instructed in [Creating a Project and Obtaining Source Code](quickstart-ide-import-project.md). 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## Example Directory 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ciThe complete code directory is as follows: 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci``` 19e41f4b71Sopenharmony_ciapplications/sample/hello 20e41f4b71Sopenharmony_ci│── BUILD.gn 21e41f4b71Sopenharmony_ci└── src 22e41f4b71Sopenharmony_ci └── helloworld.c 23e41f4b71Sopenharmony_ci``` 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci## How to Develop 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ciPerform the steps below in the source code directory: 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci1. Create a directory and the program source code. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci Create the **applications/sample/hello/src/helloworld.c** directory and file whose code is shown in the following example. You can customize the content to be printed. For example, you can change **OHOS** to **World**. You can use either C or C++ to develop a program. 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci ``` 36e41f4b71Sopenharmony_ci #include <stdio.h> 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci int main(int argc, char **argv) 39e41f4b71Sopenharmony_ci { 40e41f4b71Sopenharmony_ci printf("\n\n"); 41e41f4b71Sopenharmony_ci printf("\n\t\tHello OHOS!\n"); 42e41f4b71Sopenharmony_ci printf("\n\n\n"); 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci return 0; 45e41f4b71Sopenharmony_ci } 46e41f4b71Sopenharmony_ci ``` 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci2. Create a build file. 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci Create the **applications/sample/hello/BUILD.gn** file. The file content is as follows: 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci ``` 54e41f4b71Sopenharmony_ci import("//build/lite/config/component/lite_component.gni") 55e41f4b71Sopenharmony_ci lite_component("hello-OHOS") { 56e41f4b71Sopenharmony_ci features = [ ":helloworld" ] 57e41f4b71Sopenharmony_ci } 58e41f4b71Sopenharmony_ci executable("helloworld") { 59e41f4b71Sopenharmony_ci output_name = "helloworld" 60e41f4b71Sopenharmony_ci sources = [ "src/helloworld.c" ] 61e41f4b71Sopenharmony_ci } 62e41f4b71Sopenharmony_ci ``` 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci3. Add a component. 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci Modify the **build/lite/components/applications.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **applications.json** file, where the configuration between **\#\#start\#\#** and **\#\#end\#\#** is the new entry. (The **\#\#start\#\#** and **\#\#end\#\#** lines are only used to identify the location. After the configuration is complete, delete these lines.) 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci >  **NOTE** 69e41f4b71Sopenharmony_ci > 70e41f4b71Sopenharmony_ci > In this example, the OpenHarmony-v3.1-Release version is used, where the component configuration file is **build/lite/components/applications.json**. In OpenHarmony-v3.2-Beta2 and later versions, the component configuration file is **build/lite/components/communication.json**. 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci ``` 74e41f4b71Sopenharmony_ci { 75e41f4b71Sopenharmony_ci "components": [ 76e41f4b71Sopenharmony_ci { 77e41f4b71Sopenharmony_ci "component": "camera_sample_communication", 78e41f4b71Sopenharmony_ci "description": "Communication related samples.", 79e41f4b71Sopenharmony_ci "optional": "true", 80e41f4b71Sopenharmony_ci "dirs": [ 81e41f4b71Sopenharmony_ci "applications/sample/camera/communication" 82e41f4b71Sopenharmony_ci ], 83e41f4b71Sopenharmony_ci "targets": [ 84e41f4b71Sopenharmony_ci "//applications/sample/camera/communication:sample" 85e41f4b71Sopenharmony_ci ], 86e41f4b71Sopenharmony_ci "rom": "", 87e41f4b71Sopenharmony_ci "ram": "", 88e41f4b71Sopenharmony_ci "output": [], 89e41f4b71Sopenharmony_ci "adapted_kernel": [ "liteos_a" ], 90e41f4b71Sopenharmony_ci "features": [], 91e41f4b71Sopenharmony_ci "deps": { 92e41f4b71Sopenharmony_ci "components": [], 93e41f4b71Sopenharmony_ci "third_party": [] 94e41f4b71Sopenharmony_ci } 95e41f4b71Sopenharmony_ci }, 96e41f4b71Sopenharmony_ci ##start## 97e41f4b71Sopenharmony_ci { 98e41f4b71Sopenharmony_ci "component": "hello_world_app", 99e41f4b71Sopenharmony_ci "description": "hello world samples.", 100e41f4b71Sopenharmony_ci "optional": "true", 101e41f4b71Sopenharmony_ci "dirs": [ 102e41f4b71Sopenharmony_ci "applications/sample/hello" 103e41f4b71Sopenharmony_ci ], 104e41f4b71Sopenharmony_ci "targets": [ 105e41f4b71Sopenharmony_ci "//applications/sample/hello:hello-OHOS" 106e41f4b71Sopenharmony_ci ], 107e41f4b71Sopenharmony_ci "rom": "", 108e41f4b71Sopenharmony_ci "ram": "", 109e41f4b71Sopenharmony_ci "output": [], 110e41f4b71Sopenharmony_ci "adapted_kernel": [ "liteos_a" ], 111e41f4b71Sopenharmony_ci "features": [], 112e41f4b71Sopenharmony_ci "deps": { 113e41f4b71Sopenharmony_ci "components": [], 114e41f4b71Sopenharmony_ci "third_party": [] 115e41f4b71Sopenharmony_ci } 116e41f4b71Sopenharmony_ci }, 117e41f4b71Sopenharmony_ci ##end## 118e41f4b71Sopenharmony_ci { 119e41f4b71Sopenharmony_ci "component": "camera_sample_app", 120e41f4b71Sopenharmony_ci "description": "Camera related samples.", 121e41f4b71Sopenharmony_ci "optional": "true", 122e41f4b71Sopenharmony_ci "dirs": [ 123e41f4b71Sopenharmony_ci "applications/sample/camera/launcher", 124e41f4b71Sopenharmony_ci "applications/sample/camera/cameraApp", 125e41f4b71Sopenharmony_ci "applications/sample/camera/setting", 126e41f4b71Sopenharmony_ci "applications/sample/camera/gallery", 127e41f4b71Sopenharmony_ci "applications/sample/camera/media" 128e41f4b71Sopenharmony_ci ], 129e41f4b71Sopenharmony_ci ``` 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci4. Modify the board configuration file. 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci Modify the **vendor/hisilicon/hispark_taurus/config.json** file and add an entry for the **hello_world_app** component. The following code snippet is the configuration of the **applications** subsystem, where the configuration between **\#\#start\#\#** and **\#\#end\#\#** is the new entry. (The **\#\#start\#\#** and **\#\#end\#\#** lines are only used to identify the location. After the configuration is complete, delete these lines.) 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci ``` 137e41f4b71Sopenharmony_ci { 138e41f4b71Sopenharmony_ci "subsystem": "applications", 139e41f4b71Sopenharmony_ci "components": [ 140e41f4b71Sopenharmony_ci { "component": "camera_sample_app", "features":[] }, 141e41f4b71Sopenharmony_ci { "component": "camera_sample_ai", "features":[] }, 142e41f4b71Sopenharmony_ci ##start## 143e41f4b71Sopenharmony_ci { "component": "hello_world_app", "features":[] }, 144e41f4b71Sopenharmony_ci ##end## 145e41f4b71Sopenharmony_ci { "component": "camera_screensaver_app", "features":[] } 146e41f4b71Sopenharmony_ci ] 147e41f4b71Sopenharmony_ci }, 148e41f4b71Sopenharmony_ci ``` 149