explaingit

jart/cosmopolitan

Analysis updated 2026-06-21

20,798CAudience · developerComplexity · 4/5Setup · hard

TLDR

Cosmopolitan Libc lets you compile a C or C++ program once and run the resulting binary natively on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and BIOS, no virtual machine or per-platform build toolchain needed. It works by producing a special Actually Portable Executable format using standard GCC or Clang.

Mindmap

mindmap
  root((cosmopolitan))
    What it does
      Single cross-platform binary
      No VM needed
      Build once run anywhere
    Tech Stack
      C and C++ source
      GCC and Clang
      x86-64 hardware
      APE format
    Supported Platforms
      Linux macOS Windows
      FreeBSD OpenBSD NetBSD
      BIOS bare metal
    Use Cases
      Ship CLI tools
      Port autotools projects
      Runtime tracing
    Audience
      Systems developers
      C and C++ programmers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Ship a C command-line tool as a single binary that works on Linux, macOS, and Windows without separate per-platform builds.

USE CASE 2

Port an existing autotools C project to all major operating systems by compiling with the cosmocc wrapper instead of a standard compiler.

USE CASE 3

Debug a cross-platform C program using built-in runtime flags for system call and function call tracing without installing extra tools.

What is it built with?

CC++GCCClangx86-64

How does it compare?

jart/cosmopolitanpostgres/postgresallinurl/goaccess
Stars20,79820,82820,514
LanguageCCC
Setup difficultyhardhardmoderate
Complexity4/55/52/5
Audiencedeveloperdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires x86-64 hardware and using the cosmocc compiler wrapper instead of a standard C compiler, the APE binary format has a learning curve.

The explanation does not specify a license.

In plain English

Cosmopolitan Libc is a C library that lets you compile a C or C++ program once and have the resulting binary run natively on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and even BIOS without needing a virtual machine or interpreter. It achieves this by configuring standard compilers (GCC and Clang) to output a special file format called an Actually Portable Executable (APE), a POSIX-approved polyglot format that each operating system can understand and run directly. The key value proposition is eliminating the "build once per target platform" problem. Normally, if you want a C program to run on both Linux and Windows, you need separate build toolchains and outputs for each. Cosmopolitan produces a single binary that works everywhere. The project ships its own compiler wrapper called cosmocc, which developers use in place of a standard C compiler. Existing open-source projects that use the autotools build system can often be compiled with Cosmopolitan with minimal changes. Built-in debugging aids include --strace (logs system calls) and --ftrace (logs function call traces) flags that any Cosmopolitan program can accept at runtime. The project supports x86-64 hardware and is crowdfunded through GitHub Sponsors and Patreon.

Copy-paste prompts

Prompt 1
Show me how to compile a simple C hello-world program using Cosmopolitan cosmocc and produce an APE binary that runs on both Linux and macOS without modification.
Prompt 2
I have an existing autotools C project. Walk me through the steps to build it with Cosmopolitan Libc so it produces a single cross-platform binary.
Prompt 3
Use the --strace flag on a Cosmopolitan APE binary on Linux to trace its system calls and explain what the output means.
Prompt 4
Compare a native Linux C binary and a Cosmopolitan APE binary in terms of file size and startup overhead for a small file-processing tool.
Prompt 5
What are the known limitations of Cosmopolitan Libc? What kinds of programs or system features does it not support or approximate differently?

Frequently asked questions

What is cosmopolitan?

Cosmopolitan Libc lets you compile a C or C++ program once and run the resulting binary natively on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and BIOS, no virtual machine or per-platform build toolchain needed. It works by producing a special Actually Portable Executable format using standard GCC or Clang.

What language is cosmopolitan written in?

Mainly C. The stack also includes C, C++, GCC.

What license does cosmopolitan use?

The explanation does not specify a license.

How hard is cosmopolitan to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is cosmopolitan for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub jart on gitmyhub

Verify against the repo before relying on details.