occlum/demos/hello_bazel/README.md
LI Qing 1304f5388d Improve Occlum GCC toolchain with new wrappers for binaries
This commit makes the toolchain easier to use in two folds:
1. When compiling C/C++ source files, no need to add "-fPIC -pie" flags manually;
2. When running executables generated by the Occlum toolchain on Linux, no
need to set the `LD_LIBRARY_PATH` manually.
2019-11-29 11:20:00 +00:00

780 B

A Sample C++ Project with Bazel

This project demonstrates how to use Bazel to build C++ projects for Occlum. To install Bazel on Ubuntu, follow the instructions here.

  1. Download a Bazel sample project in C++ and build it with Occlum toolchain
./build_bazel_sample.sh

When completed, the resulting hello-world can be found in examples/cpp-tutorial/stage3/bazel-bin/main directory.

  1. (Optional) Run hello-world on Linux
./examples/cpp-tutorial/stage3/bazel-bin/main/hello-world
  1. Run hello-world on Occlum
mkdir occlum_workspace && cd occlum_workspace
occlum init
cp ../examples/cpp-tutorial/stage3/bazel-bin/main/hello-world image/bin
occlum build
occlum run /bin/hello-world