Cosmopolitan libc
lastmod 2026-01-16created 2020-12-314 edits
build-once run-anywhere c without devops
Features
- A library that makes C code runnable anywhere
- Similar to Java, but needs no interpreter or VM
- Offers Go/Rust-level portability while using plain C
- Compiling with the 5 provided library files gives Mac/Windows/Linux support as is
- Uses the fact that a Windows Portable Executable can be made into a UNIX 6th Edition shell script
- Portable, yet 100x smaller than the Go version of Hello World
Additional comments
- The well-known hacker Justine Tunney released the APE (αcτµαlly pδrταblε εxεcµταblε) format
- APE is both a UNIX shell script and a Windows executable, so it runs anywhere: Mac/Win/Linux/BSD
- Cosmopolitan is a LibC that, in this portable setting, makes C code runnable anywhere
- With this APE and Cosmpolitan, the Redbean web server, which runs as a single file, was developed
- Redbean is both an executable and a ZIP file, so it can embed all resources such as HTML/CSS/JS
- Now, in Cosmopolitan 1.0, the Redbean web server can modify the contents of the Zip file that is itself
- You can build Dynamic web pages whose content can be modified, yet it is still 1 file
- Cosmopolitan libc - Build-Once Run-Anywhere C https://news.hada.io/topic?id=3489
- Redbean - A web server that runs as 1 file https://news.hada.io/topic?id=3815
See also
Favorite site
Articles
- A game that runs on Windows, Linux, and in the browser as a single 13KiB file | GeekNews
- [Original] This game is a single 13 KiB file that runs on Windows, Linux and in the Browser. :: Kamila Szewczyk
- This game is a single 13 KiB file that runs on Windows, Linux and in the Browser | Hacker News
- A multiplatform attempt inspired by Cosmopolitan libc
- A Snake game that runs on Windows, Linux, and in the browser as a single 13KiB file, supporting all three platforms from one source
Pages that link here