samples: cpp: add a Hello, world! C++ app
Create a separate hello world C++ app for Zephyr. Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This commit is contained in:
parent
db24a8b461
commit
574e641297
8
samples/cpp/hello_world/CMakeLists.txt
Normal file
8
samples/cpp/hello_world/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(hello_cpp_world)
|
||||
|
||||
target_sources(app PRIVATE src/main.cpp)
|
33
samples/cpp/hello_world/README.rst
Normal file
33
samples/cpp/hello_world/README.rst
Normal file
|
@ -0,0 +1,33 @@
|
|||
.. _hello_cpp_world:
|
||||
|
||||
Hello C++ World
|
||||
###############
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
A simple :ref:`C++ <language_cpp>` sample that can be used with many supported board and prints
|
||||
"Hello, C++ world!" to the console.
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
This configuration can be built and executed on QEMU as follows:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/cpp/hello_world
|
||||
:host-os: unix
|
||||
:board: qemu_riscv32
|
||||
:goals: run
|
||||
:compact:
|
||||
|
||||
To build for another board, change "qemu_riscv32" above to that board's name.
|
||||
|
||||
Sample Output
|
||||
=============
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
Hello C++, world! qemu_riscv32
|
||||
|
||||
Exit QEMU by pressing :kbd:`CTRL+C`
|
2
samples/cpp/hello_world/prj.conf
Normal file
2
samples/cpp/hello_world/prj.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
CONFIG_CPP=y
|
||||
CONFIG_REQUIRES_FULL_LIBCPP=y
|
24
samples/cpp/hello_world/sample.yaml
Normal file
24
samples/cpp/hello_world/sample.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
sample:
|
||||
description: Hello World C++ sample, the simplest C++ Zephyr application
|
||||
name: hello cpp world
|
||||
common:
|
||||
tags: introduction
|
||||
integration_platforms:
|
||||
- qemu_riscv32
|
||||
harness: console
|
||||
harness_config:
|
||||
type: one_line
|
||||
regex:
|
||||
- "Hello, C\\+\\+ world! (.*)"
|
||||
tests:
|
||||
sample.cpp.helloworld:
|
||||
min_ram: 128
|
||||
arch_exclude:
|
||||
# See #66027
|
||||
- xtensa
|
||||
platform_exclude:
|
||||
# See zephyrproject-rtos/sdk-ng#593
|
||||
- qemu_x86
|
||||
- intel_ish_5_4_1
|
||||
- intel_ish_5_6_0
|
||||
- intel_ish_5_8_0
|
13
samples/cpp/hello_world/src/main.cpp
Normal file
13
samples/cpp/hello_world/src/main.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Meta
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
std::cout << "Hello, C++ world! " << CONFIG_BOARD << std::endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue