Skip to content

Commit

Permalink
feat: Introduce "Hello, world" application example in C++
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <[email protected]>
  • Loading branch information
nderjung committed Oct 23, 2023
1 parent 79f3efb commit 77eaf85
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ kraft pkg ls --apps --update
| | Example |
|-|:-|
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/icons/c.svg) | [Simple "Hello, world!" application written in C](https://github.com/unikraft/catalog/tree/main/examples/helloworld-c) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/icons/cpp.svg) | [Simple "Hello, world!" application written in C++](https://github.com/unikraft/catalog/tree/main/examples/helloworld-cpp) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/icons/python3.svg) | [Simple Flask 3.0 HTTP Web Server](https://github.com/unikraft/catalog/tree/main/examples/http-python3.10-flask3.0) |
| ![](https://raw.githubusercontent.com/unikraft/catalog/main/icons/python3.svg) | [Simple Python 3.10 HTTP Web Server with `http.server.HTTPServer`](https://github.com/unikraft/catalog/tree/main/examples/http-python3.10) |

Expand Down
26 changes: 26 additions & 0 deletions examples/helloworld-cpp/Kraftfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
spec: v0.6

name: helloworld

unikraft:
version: stable
kconfig:
CONFIG_LIBPOSIX_SYSINFO: y
CONFIG_LIBUKSIGNAL: y

targets:
- linuxu/x86_64
- qemu/x86_64
- xen/x86_64
- qemu/arm64
- fc/x86_64

libraries:
libcxxabi: stable
libcxx: stable
libunwind: stable
compiler-rt:
version: stable
kconfig:
CONFIG_LIBCOMPILER_RT: 'y'
musl: stable
3 changes: 3 additions & 0 deletions examples/helloworld-cpp/Makefile.uk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$(eval $(call addlib,apphelloworldcpp))

APPHELLOWORLDCPP_SRCS-y += $(APPHELLOWORLDCPP_BASE)/main.cpp
27 changes: 27 additions & 0 deletions examples/helloworld-cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Simple "Hello, world!" C++ Program on Unikraft

This directory contains an example "Hello, world!" application written in C++.

To run this example, [install Unikraft's companion command-line toolchain `kraft`](https://unikraft.org/docs/cli).

Then, clone this repository and cd into this directory.
You can then build the project with:

```
kraft build
```

In the above command, `kraft build` will prompt you with the target you wish to compile for.
If you are unsure, select `qemu/` and your host's architecture, e.g. `qemu/x86_64`.

Once built, you can execute the unikernel via:

```
kraft run
```

## Learn more

- [How to build unikernels](https://unikraft.org/docs/cli/building)
- [How to run unikernels locally](https://unikraft.org/docs/cli/running)
- [The `Kraftfile` specification](https://unikraft.org/docs/cli/reference/kraftfile/latest)
6 changes: 6 additions & 0 deletions examples/helloworld-cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <iostream>

int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
11 changes: 11 additions & 0 deletions icons/cpp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 77eaf85

Please sign in to comment.