.. _build_custom_app: Build Custom C/C++ App ###################### This guide provides step-by-step instructions for creating a custom C application and building it for the SiMa DevKit using the Palette SDKs. It covers developing a simple "Hello World" program, configuring it for cross-compilation, and using the SDK’s tools for building. .. note:: While cross-compilation is the standard approach for both platforms, **Modalix (eLxr)** also supports **On-Device compilation** directly on the hardware. For more details on building directly on Modalix, see the :ref:`On-Device Compilation ` section. Before you run the following commands, ensure you have followed the :ref:`cross compilation setup ` for your target platform (Yocto or eLxr). .. dropdown:: Step 1. Create the Application Source Code :animate: fade-in :color: secondary :open: First, write a simple C program as your custom application. 1. Create a project directory and navigate to it: .. code-block:: bash user@palette-container-id:/home/docker/$mkdir ~/myproject user@palette-container-id:/home/docker/$cd ~/myproject 2. Create a file named ``hello.c`` with the following content: .. code-block:: c #include int main() { printf("Hello, SiMa DevKit!\n"); return 0; } This basic program prints a greeting when executed. .. dropdown:: Step 2. Compile the Application Using the SDK :animate: fade-in :color: secondary To compile the program for the target architecture, you must be inside the correct SDK container and have the environment activated. 1. Compile the program: .. code-block:: bash user@palette-container-id:/home/docker/myproject$ $CC hello.c -o hello 2. Verify the build: .. code-block:: bash user@palette-container-id:/home/docker/myproject$ file hello Output should resemble: ``hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, ...`` .. dropdown:: Step 3. Deploy the Application to the DevKit :animate: fade-in :color: secondary To run the application, transfer it to the SiMa DevKit and execute it. 1. Copy the executable to the DevKit (e.g., via ``scp`` if networked): .. code-block:: bash user@palette-container-id:/home/docker/myproject$ scp hello sima@devkit-ip:~/ Replace ``user@devkit-ip`` with your DevKit’s SSH credentials and IP address. 2. Connect to the DevKit via SSH and run the application: .. code-block:: bash user@palette-container-id:/home/docker/myproject$ssh sima@devkit-ip "./hello" Expected output: ``Hello, SiMa DevKit!``