Build Integration
Use this page when you need to compile a C program against the installed SDK instead of just reading header-level reference docs.
Prerequisites
Section titled “Prerequisites”Start with Set Up Thru DevKit, then install the C SDK surfaces with:
thru dev toolchain installthru dev sdk install cThe CLI installs the C SDK under ~/.thru/sdk/c and the toolchain under ~/.thru/sdk/toolchain.
Verify the installed layout
Section titled “Verify the installed layout”test -d ~/.thru/sdk/ctest -f ~/.thru/sdk/c/thru-sdk/thru_c_program.mktest -d ~/.thru/sdk/toolchain/bintest -x ~/.thru/sdk/toolchain/bin/riscv64-unknown-elf-gcc || test -x ~/.thru/sdk/toolchain/bin/riscv64-none-elf-gccThe downstream makefiles auto-detect either riscv64-unknown-elf- or riscv64-none-elf-, so either compiler prefix is valid.
Main build entrypoint
Section titled “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
Section titled “Minimal GNUmakefile”THRU_C_SDK_DIR := $(HOME)/.thru/sdk/c/thru-sdkinclude $(THRU_C_SDK_DIR)/thru_c_program.mkMinimal Local.mk
Section titled “Minimal Local.mk”$(call make-bin,my_program_c,my_program,,-ltn_sdk)What THRU_C_SDK_DIR should point to
Section titled “What THRU_C_SDK_DIR should point to”Point it at the installed SDK root that contains:
thru_c_program.mkinclude/lib/config/
For the default CLI install, that means:
THRU_C_SDK_DIR := $(HOME)/.thru/sdk/c/thru-sdkProject layout that works well
Section titled “Project layout that works well”my-program/├── GNUmakefile└── examples/ ├── Local.mk ├── my_program.c └── my_program.hBuild-system guidance
Section titled “Build-system guidance”| Need | Recommendation |
|---|---|
| One or two small programs | Keep a single GNUmakefile plus per-directory Local.mk files. |
| Multiple example binaries | Add more make-bin calls in Local.mk. |
| SDK extras | Use SDK_EXTRAS when you intentionally want extra configuration layers. |
Expected build output
Section titled “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.
- The docs page is the right place to learn the installed entrypoint. The repo-local
sdks/c/setup.shis 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 internalGNUmakefile.