[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6047":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":39,"readmeContent":40,"aiSummary":41,"trendingCount":16,"starSnapshotCount":16,"syncStatus":42,"lastSyncTime":43,"discoverSource":44},6047,"cosmopolitan","jart\u002Fcosmopolitan","jart","build-once run-anywhere c library","",null,"C",20999,752,177,172,0,28,127,192,176,43.63,"ISC License",false,"master",true,[27,28,29,30,31,32,33,34,35,36,37,38],"bios","containers","darwin","efi","freebsd","libc","linux","netbsd","openbsd","polyglot","windows","zip","2026-06-12 02:01:16","![Cosmopolitan Honeybadger](usr\u002Fshare\u002Fimg\u002Fhoneybadger.png)\n\n[![build](https:\u002F\u002Fgithub.com\u002Fjart\u002Fcosmopolitan\u002Factions\u002Fworkflows\u002Fbuild.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fjart\u002Fcosmopolitan\u002Factions\u002Fworkflows\u002Fbuild.yml)\n# Cosmopolitan\n\n[Cosmopolitan Libc](https:\u002F\u002Fjustine.lol\u002Fcosmopolitan\u002Findex.html) makes C\u002FC++\na build-once run-anywhere language, like Java, except it doesn't need an\ninterpreter or virtual machine. Instead, it reconfigures stock GCC and\nClang to output a POSIX-approved polyglot format that runs natively on\nLinux + Mac + Windows + FreeBSD + OpenBSD 7.3 + NetBSD + BIOS with the\nbest possible performance and the tiniest footprint imaginable.\n\n## Background\n\nFor an introduction to this project, please read the [actually portable\nexecutable](https:\u002F\u002Fjustine.lol\u002Fape.html) blog post and [cosmopolitan\nlibc](https:\u002F\u002Fjustine.lol\u002Fcosmopolitan\u002Findex.html) website. We also have\n[API\ndocumentation](https:\u002F\u002Fjustine.lol\u002Fcosmopolitan\u002Fdocumentation.html).\n\n## Getting Started\n\nYou can start by obtaining a release of our `cosmocc` compiler from\n\u003Chttps:\u002F\u002Fcosmo.zip\u002Fpub\u002Fcosmocc\u002F>.\n\n```sh\nmkdir -p cosmocc\ncd cosmocc\nwget https:\u002F\u002Fcosmo.zip\u002Fpub\u002Fcosmocc\u002Fcosmocc.zip\nunzip cosmocc.zip\n```\n\nHere's an example program we can write:\n\n```c\n\u002F\u002F hello.c\n#include \u003Cstdio.h>\n\nint main() {\n  printf(\"hello world\\n\");\n}\n```\n\nIt can be compiled as follows:\n\n```sh\ncosmocc -o hello hello.c\n.\u002Fhello\n```\n\nThe Cosmopolitan Libc runtime links some heavyweight troubleshooting\nfeatures by default, which are very useful for developers and admins.\nHere's how you can log system calls:\n\n```sh\n.\u002Fhello --strace\n```\n\nHere's how you can get a much more verbose log of function calls:\n\n```sh\n.\u002Fhello --ftrace\n```\n\nYou can use the Cosmopolitan's toolchain to build conventional open\nsource projects which use autotools. This strategy normally works:\n\n```sh\nexport CC=x86_64-unknown-cosmo-cc\nexport CXX=x86_64-unknown-cosmo-c++\n.\u002Fconfigure --prefix=\u002Fopt\u002Fcosmos\u002Fx86_64\nmake -j\nmake install\n```\n\n## Cosmopolitan Source Builds\n\nCosmopolitan can be compiled from source on any of our supported\nplatforms. The Makefile will download cosmocc automatically.\n\nIt's recommended that you install a systemwide APE Loader. This command\nrequires `sudo` access to copy the `ape` command to a system folder and\nregister with binfmt_misc on Linux, for even more performance.\n\n```sh\nape\u002Fapeinstall.sh\n```\n\nYou can now build the mono repo with any modern version of GNU Make. To\nbootstrap your build, you can install Cosmopolitan Make from this site:\n\nhttps:\u002F\u002Fcosmo.zip\u002Fpub\u002Fcosmos\u002Fbin\u002Fmake\n\nE.g.:\n\n```sh\ncurl -LO https:\u002F\u002Fcosmo.zip\u002Fpub\u002Fcosmos\u002Fbin\u002Fmake\n.\u002Fmake -j8\no\u002F\u002Fexamples\u002Fhello\n```\n\nAfter you've built the repo once, you can also use the make from your\ncosmocc at `.cosmocc\u002Fcurrent\u002Fbin\u002Fmake`. You might even prefer to alias\nmake to `$COSMO\u002F.cosmocc\u002Fcurrent\u002Fbin\u002Fmake`.\n\nSince the Cosmopolitan repository is very large, you might only want to\nbuild one particular thing. Here's an example of a target that can be\ncompiled relatively quickly, which is a simple POSIX test that only\ndepends on core LIBC packages.\n\n```sh\nrm -rf o\u002F\u002Flibc o\u002F\u002Ftest\n.cosmocc\u002Fcurrent\u002Fbin\u002Fmake o\u002F\u002Ftest\u002Fposix\u002Fsignal_test\no\u002F\u002Ftest\u002Fposix\u002Fsignal_test\n```\n\nSometimes it's desirable to build a subset of targets, without having to\nlist out each individual one. For example if you wanted to build and run\nall the unit tests in the `TEST_POSIX` package, you could say:\n\n```sh\n.cosmocc\u002Fcurrent\u002Fbin\u002Fmake o\u002F\u002Ftest\u002Fposix\n```\n\nCosmopolitan provides a variety of build modes. For example, if you want\nreally tiny binaries (as small as 12kb in size) then you'd say:\n\n```sh\n.cosmocc\u002Fcurrent\u002Fbin\u002Fmake m=tiny\n```\n\nYou can furthermore cut out the bloat of other operating systems, and\nhave Cosmopolitan become much more similar to Musl Libc.\n\n```sh\n.cosmocc\u002Fcurrent\u002Fbin\u002Fmake m=tinylinux\n```\n\nFor further details, see [\u002F\u002Fbuild\u002Fconfig.mk](build\u002Fconfig.mk).\n\n## Debugging\n\nTo print a log of system calls to stderr:\n\n```sh\ncosmocc -o hello hello.c\n.\u002Fhello --strace\n```\n\nTo print a log of function calls to stderr:\n\n```sh\ncosmocc -o hello hello.c\n.\u002Fhello --ftrace\n```\n\nBoth strace and ftrace use the unbreakable kprintf() facility, which is\nable to be sent to a file by setting an environment variable.\n\n```sh\nexport KPRINTF_LOG=log\n.\u002Fhello --strace\n```\n\n## GDB\n\nHere's the recommended `~\u002F.gdbinit` config:\n\n```gdb\nset host-charset UTF-8\nset target-charset UTF-8\nset target-wide-charset UTF-8\nset osabi none\nset complaints 0\nset confirm off\nset history save on\nset history filename ~\u002F.gdb_history\ndefine asm\n  layout asm\n  layout reg\nend\ndefine src\n  layout src\n  layout reg\nend\nsrc\n```\n\nYou normally run the `.dbg` file under gdb. If you need to debug the\n`` file itself, then you can load the debug symbols independently as\n\n```sh\ngdb foo -ex 'add-symbol-file foo.dbg 0x401000'\n```\n\n## Platform Notes\n\n### Shells\n\nIf you use zsh and have trouble running APE programs try `sh -c .\u002Fprog`\nor simply upgrade to zsh 5.9+ (since we patched it two years ago). The\nsame is the case for Python `subprocess`, old versions of fish, etc.\n\n### Linux\n\nSome Linux systems are configured to launch MZ executables under WINE.\nOther distros configure their stock installs so that APE programs will\nprint \"run-detectors: unable to find an interpreter\". For example:\n\n```sh\njart@ubuntu:~$ wget https:\u002F\u002Fcosmo.zip\u002Fpub\u002Fcosmos\u002Fbin\u002Fdash\njart@ubuntu:~$ chmod +x dash\njart@ubuntu:~$ .\u002Fdash\nrun-detectors: unable to find an interpreter for .\u002Fdash\n```\n\nYou can fix that by registering APE with `binfmt_misc`:\n\n```sh\nsudo wget -O \u002Fusr\u002Fbin\u002Fape https:\u002F\u002Fcosmo.zip\u002Fpub\u002Fcosmos\u002Fbin\u002Fape-$(uname -m).elf\nsudo chmod +x \u002Fusr\u002Fbin\u002Fape\nsudo sh -c \"echo ':APE:M::MZqFpD::\u002Fusr\u002Fbin\u002Fape:' >\u002Fproc\u002Fsys\u002Ffs\u002Fbinfmt_misc\u002Fregister\"\nsudo sh -c \"echo ':APE-jart:M::jartsr::\u002Fusr\u002Fbin\u002Fape:' >\u002Fproc\u002Fsys\u002Ffs\u002Fbinfmt_misc\u002Fregister\"\n```\n\nYou should be good now. APE will not only work, it'll launch executables\n400µs faster now too. However if things still didn't work out, it's also\npossible to disable `binfmt_misc` as follows:\n\n```sh\nsudo sh -c 'echo -1 > \u002Fproc\u002Fsys\u002Ffs\u002Fbinfmt_misc\u002Fcli'     # remove Ubuntu's MZ interpreter\nsudo sh -c 'echo -1 > \u002Fproc\u002Fsys\u002Ffs\u002Fbinfmt_misc\u002Fstatus'  # remove ALL binfmt_misc entries\n```\n\n### WSL\n\nIt's normally unsafe to use APE in a WSL environment, because it tries\nto run MZ executables as WIN32 binaries within the WSL environment. In\norder to make it safe to use Cosmopolitan software on WSL, run this:\n\n```sh\nsudo sh -c \"echo -1 > \u002Fproc\u002Fsys\u002Ffs\u002Fbinfmt_misc\u002FWSLInterop\"\n```\n\n## Discord Chatroom\n\nThe Cosmopolitan development team collaborates on the Redbean Discord\nserver. You're welcome to join us! \u003Chttps:\u002F\u002Fdiscord.gg\u002FFwAVVu7eJ4>\n\n## Support Vector\n\n| Platform       | Min Version    | Circa |\n| :---           | ---:           | ---:  |\n| AMD            | K8             | 2003  |\n| Intel          | Core           | 2006  |\n| Linux          | 2.6.18         | 2007  |\n| Windows        | 8 [1]          | 2012  |\n| Darwin (macOS) | 23.1.0+        | 2023  |\n| OpenBSD        | 7.3 or earlier | 2023  |\n| FreeBSD        | 13             | 2020  |\n| NetBSD         | 9.2            | 2021  |\n\n[1] See our [vista branch](https:\u002F\u002Fgithub.com\u002Fjart\u002Fcosmopolitan\u002Ftree\u002Fvista)\n    for a community supported version of Cosmopolitan that works on Windows\n    Vista and Windows 7.\n\n## Special Thanks\n\nFunding for this project is crowdsourced using\n[GitHub Sponsors](https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fjart) and\n[Patreon](https:\u002F\u002Fwww.patreon.com\u002Fjart). Your support is what makes this\nproject possible. Thank you! We'd also like to give special thanks to\nthe following groups and individuals:\n\n- [Joe Drumgoole](https:\u002F\u002Fgithub.com\u002Fjdrumgoole)\n- [Rob Figueiredo](https:\u002F\u002Fgithub.com\u002Frobfig)\n- [Wasmer](https:\u002F\u002Fwasmer.io\u002F)\n\nFor publicly sponsoring our work at the highest tier.\n","Cosmopolitan是一个构建一次即可在任意平台运行的C\u002FC++库，类似于Java但无需解释器或虚拟机。它通过重新配置标准GCC和Clang编译器生成符合POSIX标准的多语言格式文件，能够在Linux、Mac、Windows、FreeBSD、OpenBSD 7.3、NetBSD以及BIOS上原生运行，同时保持最佳性能和最小的内存占用。项目提供了详细的API文档和支持多种调试工具如系统调用日志和函数调用跟踪，非常适合需要跨平台支持且对性能有较高要求的应用场景开发，比如构建便携式命令行工具或者轻量级服务等。",2,"2026-06-11 03:05:32","top_language"]