Getting started

From first include to a stamped binary.

This matches the frontera-consumer example: one protected function, one build driver, one stamp.

1. Build Frontera

From the Frontera repository root, build the static library, tools, and optional phomo dependency. Passing your app directory installs headers and archives there:

shellbash
./scripts/build-all.sh /path/to/your-app

You should get libfrontera.a, frontera-protect,frontera-stamp, headers under your include path, and usuallylibphomo.a when the sibling phomo tree is available.

2. Write the translation unit

Include the umbrella header and place FRONTERA_INIT() at file scope. Mark sensitive functions with [[frontera::protect]] (or a// frontera:protect comment on the previous line).

main.cppC++ · GNU/Linux
#include "frontera.hpp"
FRONTERA_INIT();

#include <cstdio>

[[frontera::protect]]
int returnLicense()
{
    int license = 2;
    license = license + (2 ^ 4);
    return license;
}

int main()
{
    std::printf("%d\n", returnLicense());
    return 0;
}

FRONTERA_INIT() does not start antitamper during static construction—the D runtime is not ready yet. The first entry into a protected function (after frontera-protect rewrite) calls frontera_at_start() once. You can also call frontera::runtime_init() explicitly from main.

3. Compile through the Frontera driver

Do not compile protected sources with a bare g++ alone. Usecxx-frontera.sh so marked functions are rewritten to rolling-key VM stubs and the output binary is stamped:

buildbash
# From your app directory (sibling to frontera):
./../frontera/scripts/build-all.sh "$(pwd)"

../frontera/scripts/cxx-frontera.sh g++ main.cpp \
  -std=c++20 -I. -O2 ./libfrontera.a \
  -L"$HOME/dlang/ldc-1.42.0/lib" -lphobos2-ldc -ldruntime-ldc \
  -lpthread -ldl -lm \
  -o myapp

The driver appends libphomo.a, -lelf, and -lz when phomo is present. Adjust LDC_LIB to your LDC Phobos/druntime path.

4. Run

On bare metal you should see the function result (for the sample above, 8). Inside a hypervisor, Frontera may hard-exit. For VM-only development:

shellbash
g++ ... -DFRONTERA_SKIP_AT=1 ...   # never ship with this

Must stamp after link. The digest slot lives inlibfrontera; frontera-stamp writes the SHA-256 after the binary exists. Skipping the stamp makes self-integrity fail.