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## Example Directory 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciThe complete code directory is as follows: 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci``` 14e41f4b71Sopenharmony_ciapplications/sample/hello 15e41f4b71Sopenharmony_ci│── BUILD.gn 16e41f4b71Sopenharmony_ci└── src 17e41f4b71Sopenharmony_ci └── helloworld.c 18e41f4b71Sopenharmony_ci``` 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## How to Develop 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciPerform the steps below in the source code directory: 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci1. Create a directory and the program source code. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_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. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci ``` 31e41f4b71Sopenharmony_ci #include <stdio.h> 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci int main(int argc, char **argv) 34e41f4b71Sopenharmony_ci { 35e41f4b71Sopenharmony_ci printf("\n\n"); 36e41f4b71Sopenharmony_ci printf("\n\t\tHello OHOS!\n"); 37e41f4b71Sopenharmony_ci printf("\n\n\n"); 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci return 0; 40e41f4b71Sopenharmony_ci } 41e41f4b71Sopenharmony_ci ``` 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci2. Create a build file. 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci Create the **applications/sample/hello/BUILD.gn** file. The file content is as follows: 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci ``` 49e41f4b71Sopenharmony_ci import("//build/lite/config/component/lite_component.gni") 50e41f4b71Sopenharmony_ci lite_component("hello-OHOS") { 51e41f4b71Sopenharmony_ci features = [ ":helloworld" ] 52e41f4b71Sopenharmony_ci } 53e41f4b71Sopenharmony_ci executable("helloworld") { 54e41f4b71Sopenharmony_ci output_name = "helloworld" 55e41f4b71Sopenharmony_ci sources = [ "src/helloworld.c" ] 56e41f4b71Sopenharmony_ci } 57e41f4b71Sopenharmony_ci ``` 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci3. Add a component. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci Modify the **build/lite/components/communication.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **communication.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.) 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci ``` 65e41f4b71Sopenharmony_ci { 66e41f4b71Sopenharmony_ci "components": [ 67e41f4b71Sopenharmony_ci { 68e41f4b71Sopenharmony_ci "component": "camera_sample_communication", 69e41f4b71Sopenharmony_ci "description": "Communication related samples.", 70e41f4b71Sopenharmony_ci "optional": "true", 71e41f4b71Sopenharmony_ci "dirs": [ 72e41f4b71Sopenharmony_ci "applications/sample/camera/communication" 73e41f4b71Sopenharmony_ci ], 74e41f4b71Sopenharmony_ci "targets": [ 75e41f4b71Sopenharmony_ci "//applications/sample/camera/communication:sample" 76e41f4b71Sopenharmony_ci ], 77e41f4b71Sopenharmony_ci "rom": "", 78e41f4b71Sopenharmony_ci "ram": "", 79e41f4b71Sopenharmony_ci "output": [], 80e41f4b71Sopenharmony_ci "adapted_kernel": [ "liteos_a" ], 81e41f4b71Sopenharmony_ci "features": [], 82e41f4b71Sopenharmony_ci "deps": { 83e41f4b71Sopenharmony_ci "components": [], 84e41f4b71Sopenharmony_ci "third_party": [] 85e41f4b71Sopenharmony_ci } 86e41f4b71Sopenharmony_ci }, 87e41f4b71Sopenharmony_ci ##start## 88e41f4b71Sopenharmony_ci { 89e41f4b71Sopenharmony_ci "component": "hello_world_app", 90e41f4b71Sopenharmony_ci "description": "hello world samples.", 91e41f4b71Sopenharmony_ci "optional": "true", 92e41f4b71Sopenharmony_ci "dirs": [ 93e41f4b71Sopenharmony_ci "applications/sample/hello" 94e41f4b71Sopenharmony_ci ], 95e41f4b71Sopenharmony_ci "targets": [ 96e41f4b71Sopenharmony_ci "//applications/sample/hello:hello-OHOS" 97e41f4b71Sopenharmony_ci ], 98e41f4b71Sopenharmony_ci "rom": "", 99e41f4b71Sopenharmony_ci "ram": "", 100e41f4b71Sopenharmony_ci "output": [], 101e41f4b71Sopenharmony_ci "adapted_kernel": [ "liteos_a" ], 102e41f4b71Sopenharmony_ci "features": [], 103e41f4b71Sopenharmony_ci "deps": { 104e41f4b71Sopenharmony_ci "components": [], 105e41f4b71Sopenharmony_ci "third_party": [] 106e41f4b71Sopenharmony_ci } 107e41f4b71Sopenharmony_ci }, 108e41f4b71Sopenharmony_ci ##end## 109e41f4b71Sopenharmony_ci { 110e41f4b71Sopenharmony_ci "component": "camera_sample_app", 111e41f4b71Sopenharmony_ci "description": "Camera related samples.", 112e41f4b71Sopenharmony_ci "optional": "true", 113e41f4b71Sopenharmony_ci "dirs": [ 114e41f4b71Sopenharmony_ci "applications/sample/camera/launcher", 115e41f4b71Sopenharmony_ci "applications/sample/camera/cameraApp", 116e41f4b71Sopenharmony_ci "applications/sample/camera/setting", 117e41f4b71Sopenharmony_ci "applications/sample/camera/gallery", 118e41f4b71Sopenharmony_ci "applications/sample/camera/media" 119e41f4b71Sopenharmony_ci ], 120e41f4b71Sopenharmony_ci ``` 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci4. Modify the board configuration file. 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_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.) 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci ``` 128e41f4b71Sopenharmony_ci { 129e41f4b71Sopenharmony_ci "subsystem": "applications", 130e41f4b71Sopenharmony_ci "components": [ 131e41f4b71Sopenharmony_ci { "component": "camera_sample_app", "features":[] }, 132e41f4b71Sopenharmony_ci { "component": "camera_sample_ai", "features":[] }, 133e41f4b71Sopenharmony_ci ##start## 134e41f4b71Sopenharmony_ci { "component": "hello_world_app", "features":[] }, 135e41f4b71Sopenharmony_ci ##end## 136e41f4b71Sopenharmony_ci { "component": "camera_screensaver_app", "features":[] } 137e41f4b71Sopenharmony_ci ] 138e41f4b71Sopenharmony_ci }, 139e41f4b71Sopenharmony_ci ``` 140