3768037b471190a579e9f703ea0fcd1c004cba44
[AGL/documentation.git] / docs / 3_Developer_Guides / 2_Building_Microservices_Natively / 5_building-and-running-service-natively.md
1 ---
2 edit_link: ''
3 title: Building and Running Your Service Natively
4 origin_url: >-
5   https://raw.githubusercontent.com/automotive-grade-linux/docs-sources/master/agl-documentation/host-configuration/docs/5-building-and-running-service-natively.md
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/devguides/master/host-configuration-developer-guides-devguides-book.yml -->
9
10 # Building and Running Your Service Natively
11
12 The next step in the binder development process is to build your
13 binder and run it using your native Linux system.
14
15 **NOTE:** This section assumes using the `helloworld-service` example
16 and completion of the previous steps in this
17 "[Building Microservices Natively](./0-build-microservice-overview.html)"
18 section.
19
20 ## Building the Service
21
22 Move to the cloned `helloworld-service` repository and build the service
23 using either of the following methods:
24
25 * ```bash
26   cd helloworld-service
27   ./conf.d/autobuild/linux/autobuild package
28   ```
29
30 * ```bash
31   cd helloworld-service
32   mkdir build
33   cd build
34   cmake ..
35   make
36   ```
37
38 ## Running the Service
39
40 You use the Application Framework Binder Daemon (`afb-daemon`) to
41 bind one instance of an application or service to the rest of the system.
42 In this example, you are binding an instance of `helloworld-service`
43 to the rest of the system:
44
45 ```bash
46 afb-daemon --binding helloworld.so --port 3333 --token ''
47 ```
48
49 The previous command starts `afb-daemon` and loads the `helloworld.so`
50 binding.
51 The daemon is now listening on port 3333 of the `localhost`.
52
53 ## Testing the Service
54
55 Refer to the
56 [AGL Test Framework](../../apis_services/#agl-test-framework) topic in the
57 "APIs & Services" topic.
58 You can test your `helloworld-service` binding using the `afm-test` tool.
59
60 Examine the generic example describing how to launch the tests suite
61 [here](../../apis_services/reference/afb-test/3_Launch_the_tests.html).
62 This example can help you understand how to test your helloworld binding
63 instance.
64
65 ## Using Optional Tools
66
67 Once you have built and run your micro-service successfully using your
68 native Linux system, you should consider using some additional
69 development tools: X(Cross) Development System (XDS) and
70 the Controller Area Network (CAN) Development Studio (CANdevStudio).
71
72 * **XDS:** Cross-compiles and ports your AGL image to your target hardware.
73 For information on XDS, see the
74 "[X(cross) Development System: User's Guide](../reference/xds/part-1/xds-overview.html)"
75 section.
76
77 * **CANdevStudio:** Simulates CAN signals such as ignition status,
78 doors status, or reverse gear by every automotive developer.
79 For information on CANdevStudio, see the
80 "[CANdevStudio Quickstart](../../apis_services/reference/candevstudio/1_Usage.html)"
81 section.
82
83 ## Troubleshooting
84
85 ### systemd and/or libmicrohttpd
86
87 If you encounter an error message similar to the following,
88 you need to make some changes to your `cmake` file:
89
90 ```shell
91 -- Checking for module 'libmicrohttpd>=0.9.60'
92 --   No package 'libmicrohttpd' found
93 CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:415 (message):
94   A required package was not found
95 Call Stack (most recent call first):
96   /usr/share/cmake/Modules/FindPkgConfig.cmake:593 (_pkg_check_modules_internal)
97   conf.d/app-templates/cmake/cmake.d/01-build_options.cmake:92 (PKG_CHECK_MODULES)
98   conf.d/app-templates/cmake/common.cmake:77 (include)
99   conf.d/cmake/config.cmake:184 (include)
100   CMakeLists.txt:3 (include)
101 ```
102
103 Open the `config.cmake` file located in `helloworld-service/conf.d/cmake/` directory
104 and add a hash character (i.e. #) to the beginning of the "libsystemd>=222"
105 and "libmicrohttpd>=0.9.60" strings.
106 Following is an example of the edits:
107
108 ```CMake
109   set (PKG_REQUIRED_LIST
110     json-c
111     #libsystemd>=222
112     afb-daemon
113     #libmicrohttpd>=0.9.60
114   )
115 ```
116
117 After making these changes, rebuild the service again as described in the
118 "[Building the Service](./4-getting-source-files.html#building-the-service)"
119 section previously on this page.