zc-ape (Zen-C Actually Portable Executable) is a distribution of the Zen-C transpiler built as an Actually Portable Executable (APE) using Cosmopolitan Libc. This project aims to bring all advantages of CosmoCC to the Zen-C growing ecosystem, so the produced binaries and compiler itself are runnable on multiple OSes and Archs.
The easiest way to get started is to download zc-boot.com from the Releases page.
# Create a project dir
mkdir my-project
cd my-project
# Download zc-boot.com
curl -L -o zc-boot.com https://github.com/OEvgeny/zc-ape/releases/latest/download/zc-boot.com
# Make it executable
chmod +x zc-boot.com
# Run it (downloads toolchain and sets up environment)
./zc-boot.com
# Build and run the hello world example
usr/bin/make
./out/hello.comUpon running zc-boot.com does the following
- Sets up
usr/bindirectory structure - Downloads
cosmocctoolchain - Downloads
zip/unziputilities as APE binaries - Downloads pre-built
zc.comfrom this repo releases page - Extracts example files (
hello.zc,Makefile) - Displays instructions for building your first Zen-C program
Known Issues:
- Some systems may need
curlutility available inPATHsee #1 - Some systems may need
unziputility available inPATHsee #2 - Zen-C plugins are not currently supported in APE builds
After cloning the repository:
git clone https://github.com/OEvgeny/zc-ape.git
# or over SSH:
git clone git@github.com:OEvgeny/zc-ape.git
cd zc-apeRun the following commands to obtain required tools and perform the build:
./boot-repo.com # Initialize submodules, download toolchain into ./usr/bin
usr/bin/make # Build zc.com and zc-boot.comThe build process produces:
-
out/bin/zc.com: The Zen-C compiler as an APE binary- Includes embedded standard library (
std.zc,std/) - Can compile Zen-C source files to native executables
- Includes embedded standard library (
-
out/bin/zc-boot.com: Bootstrap installer- Self-contained setup script for new projects
zc-ape/
├── boot-repo.com # Repository bootstrapper files
├── zc-ape/ # Zen-C APE entry point wrapper
│ └── zc_entry.c #
├── zc-boot/ # Bootstrap project files
│ ├── boot.zc #
├── third-party/Zen-C/ # Zen-C transpiler
└── usr/ # Toolchain installation directory
└── bin/ #
To build your own Zen-C programs as APE binaries:
# Use the built zc.com compiler
out/bin/zc.com build --cc usr/bin/cosmocc -o myprogram.com myprogram.zc
# The resulting .com file runs on all platforms
./myprogram.com- Cosmopolitan Libc: makes C/C++ a build-once run-anywhere language by Justine Tunney
- Cosmocc: C compiler producing APE binaries by Justine Tunney and others (see LEGAL section)
- Zen-C: Modern systems language with C compatibility by z-libs team
Contributions are welcome! Please feel free to submit issues or pull requests.