Skip to content

miho/VTCC

Repository files navigation

VTCC

Download Build status Build Status

Compile and Run C code from Java via embedded TCC Compiler (Works on Linux, Windows and macOS)

Usage:

To execute C code, the following method can be used:

// execute C code"
String code = "#include <stdio.h>\n" +
              "int main(int argc, char* argv[]) {\n" +
              "  printf(\"Hello, World!\\n\");\n"+
              "  return 0;\n"+
              "}";
CInterpreter.execute(code);

To execute a specified C script, use:

// execute main.c
CInterpreter.execute(new File("main.c"));

To print the output to given print streams, use the print(...) method:

// execute main.c
CInterpreter.execute(new File("main.c")).print(System.out,System.err);

To wait until the execution has finished, use the waitFor() method:

// execute main.c and wait until exution finishes"
CInterpreter.execute(new File("main.c")).waitFor();

The exit value can be accessed via:

// execute main.c
CInterpreter.execute(new File("main.c")).getProcess().exitValue();

To destroy the current process, the destroy()method can be used:

// execute main.c
CInterpreter.execute(new File("main.c")).destroy();

How to Build VTCC

Requirements

  • Java >= 1.8
  • Internet connection (dependencies are downloaded automatically)
  • IDE: Gradle Plugin (not necessary for command line usage)

IDE

Open the VTCC Gradle project in your favourite IDE and build it by calling the assemble task.

Command Line

Navigate to the Gradle project (e.g., path/to/VTCC) and enter the following command

Bash (Linux/OS X/Cygwin/other Unix-like Shell)

sh gradlew assemble

Windows (CMD)

gradlew assemble

About

Compile and Run C code from Java via embedded Compiler (Works on Linux, Windows and macOS)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages