/RuntimeCompiler

Runtime C compilation using Fabrice Bellard's Tiny C Compiler

Primary LanguageC++Creative Commons Zero v1.0 UniversalCC0-1.0

Compiling C at runtime using the Tiny C Compiler

Overview

Tiny C Compiler (tcc) allows runtime C compilation. Using it as a library (libtcc), we can compile C code and access its compiled symbols at runtime. The goal of this exercise is to tie it together with a bit of C++ to demonstrate how it would fare in a C++ codebase.

Demonstrated features

  • runtime C code compilation
  • expose C++ code as extern C code and call it from the runtime-compiled script
  • ExternalProject setup for tcc

Instructions

mkdir build; cd build
cmake .. && make && make install

# launch the demo binary
bin/tinyccdemo ../scripts/cscript.c