Skip to main content
Use this page when you need to compile a C program against the installed SDK instead of just reading header-level reference docs.

Prerequisites

Start with Set Up Thru DevKit, then install the C SDK surfaces with:
thru-cli dev toolchain install
thru-cli dev sdk install c
The CLI installs the C SDK under ~/.thru/sdk/c and the toolchain under ~/.thru/sdk/toolchain.

Verify the installed layout

test -d ~/.thru/sdk/c
test -f ~/.thru/sdk/c/thru-sdk/thru_c_program.mk
test -d ~/.thru/sdk/toolchain/bin
test -x ~/.thru/sdk/toolchain/bin/riscv64-unknown-elf-gcc || test -x ~/.thru/sdk/toolchain/bin/riscv64-none-elf-gcc
The downstream makefiles auto-detect either riscv64-unknown-elf- or riscv64-none-elf-, so either compiler prefix is valid.

Main build entrypoint

The installed downstream build hook is thru_c_program.mk. Its job is to:
  • require THRU_C_SDK_DIR
  • add SDK include paths through CPPFLAGS
  • add SDK library paths through LDFLAGS
  • include machine and config files for the Thru VM toolchain

Minimal GNUmakefile

THRU_C_SDK_DIR := $(HOME)/.thru/sdk/c/thru-sdk
include $(THRU_C_SDK_DIR)/thru_c_program.mk

Minimal Local.mk

$(call make-bin,my_program_c,my_program,,-ltn_sdk)

What THRU_C_SDK_DIR should point to

Point it at the installed SDK root that contains:
  • thru_c_program.mk
  • include/
  • lib/
  • config/
For the default CLI install, that means:
THRU_C_SDK_DIR := $(HOME)/.thru/sdk/c/thru-sdk

Project layout that works well

my-program/
├── GNUmakefile
└── examples/
    ├── Local.mk
    ├── my_program.c
    └── my_program.h

Build-system guidance

NeedRecommendation
One or two small programsKeep a single GNUmakefile plus per-directory Local.mk files.
Multiple example binariesAdd more make-bin calls in Local.mk.
SDK extrasUse SDK_EXTRAS when you intentionally want extra configuration layers.

Expected build output

For the standard downstream project layout used in the C guide, the built binary lands under:
build/thruvm/bin/
That is the path shape the rest of the docs currently assume for deployment examples.

Notes

  • The docs page is the right place to learn the installed entrypoint. The repo-local sdks/c/setup.sh is not the end-user install path you should default to.
  • If a task is “build a downstream program,” start with thru_c_program.mk, not the SDK’s internal GNUmakefile.