Skip to main content

TinyCC compiler bundle for windows

Project description

TinyCC (or tcc) is a small, fast C compiler capable of producing DLLs that can be loaded via ctypes. This version compiles for 64 bit Windows.

Compiler version: 0.9.26 (amd64) 2013-02-16

Installation of the compiler and the python interface is simply:

pip install tinycc

Full documentation for the compiler is available at Source and binaries are available from

TCC is the full path to the tcc.exe executable, wrapped in quotes so that it can be used as part of an os.system command even when it contains spaces. The function find_tcc_path() returns the path without quotes.

Usage example:

import os
from tinycc import TCC

COMPILE = TCC + " -shared -rdynamic -Wall %(source)s -o %(target)s"

source = "hello.c"
target = os.path.splitext(source)[0] + ".dll"  # replace .c with .dll
command = COMPILE%{"source": source, "target": target}
status = os.system(command)
if status != 0 or not os.path.exists(target):
    raise RuntimeError("compile failed.  File is in %r"%source)

or more simply, use compile:

from tinycc import compile
dll_path = compile("hello.c")

Use data_files to gather the data files required for bundling tinycc in a py2exe package. This places the compiler in the tinycc-data directory beside the generated by py2exe. The following should appear in the for the py2exe build:

import tinycc

data_files = []
    data_files = data_files,

Project details

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page