diff --git a/README.md b/README.md index 4e88f03b..d3469bf4 100644 --- a/README.md +++ b/README.md @@ -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) | diff --git a/examples/helloworld-cpp/Kraftfile b/examples/helloworld-cpp/Kraftfile new file mode 100644 index 00000000..da139a54 --- /dev/null +++ b/examples/helloworld-cpp/Kraftfile @@ -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 diff --git a/examples/helloworld-cpp/Makefile.uk b/examples/helloworld-cpp/Makefile.uk new file mode 100644 index 00000000..15a3e675 --- /dev/null +++ b/examples/helloworld-cpp/Makefile.uk @@ -0,0 +1,3 @@ +$(eval $(call addlib,apphelloworldcpp)) + +APPHELLOWORLDCPP_SRCS-y += $(APPHELLOWORLDCPP_BASE)/main.cpp diff --git a/examples/helloworld-cpp/README.md b/examples/helloworld-cpp/README.md new file mode 100644 index 00000000..07e9f9af --- /dev/null +++ b/examples/helloworld-cpp/README.md @@ -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) diff --git a/examples/helloworld-cpp/main.cpp b/examples/helloworld-cpp/main.cpp new file mode 100644 index 00000000..928e7b03 --- /dev/null +++ b/examples/helloworld-cpp/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello World!" << std::endl; + return 0; +} diff --git a/icons/cpp.svg b/icons/cpp.svg new file mode 100644 index 00000000..bcf4c6fd --- /dev/null +++ b/icons/cpp.svg @@ -0,0 +1,11 @@ + + + + + + + + + + +