All Projects → Yardanico → cosmonim

Yardanico / cosmonim

Licence: MIT License
A simple example to show how cosmopolitan libc can be used with Nim

Programming Languages

nim
578 projects

Projects that are alternatives of or similar to cosmonim

LibPortablePlus
-----
Stars: ✭ 17 (-81.11%)
Mutual labels:  portable
webgui
Web Technologies based Crossplatform GUI Framework with Dark theme
Stars: ✭ 81 (-10%)
Mutual labels:  nim-lang
nextcloud-portable
🚀 Nextcloud portable for Windows
Stars: ✭ 21 (-76.67%)
Mutual labels:  portable
nim magic
Nim cell magic for JupyterLab or Juypter Python Notebooks.
Stars: ✭ 41 (-54.44%)
Mutual labels:  nim-lang
nim-telegram-bot
Nim Telegram Bot.
Stars: ✭ 18 (-80%)
Mutual labels:  nim-lang
dot-templater
A small, portable Rust program intended for templating dotfiles across multiple systems.
Stars: ✭ 41 (-54.44%)
Mutual labels:  portable
rkorova
ld_preload userland rootkit
Stars: ✭ 34 (-62.22%)
Mutual labels:  libc
java-portable
Install a portable version of the JDK (and bundled JRE) and run it everywhere without admin rights on Windows.
Stars: ✭ 22 (-75.56%)
Mutual labels:  portable
teamspeak-client-portable
🚀 TeamSpeak Client portable for Windows
Stars: ✭ 21 (-76.67%)
Mutual labels:  portable
Neel
A Nim library for making Electron-like HTML/JS GUI apps, with full access to Nim capabilities.
Stars: ✭ 144 (+60%)
Mutual labels:  nim-lang
cadru
A Microsoft .NET Framework toolkit
Stars: ✭ 58 (-35.56%)
Mutual labels:  portable
FullProxy
Bind and reverse connection based, SOCKS5, HTTP and PortForward based portable proxy
Stars: ✭ 22 (-75.56%)
Mutual labels:  portable
lastfm
Portable .Net library for Last.fm
Stars: ✭ 87 (-3.33%)
Mutual labels:  portable
tge
Game Runtime in GO, aims to provide a light, portable and unopiniated runtime to integrate GO libraries to portable applications (dektop, web & mobile).
Stars: ✭ 30 (-66.67%)
Mutual labels:  portable
wymlp
tiny fast portable real-time deep neural network for regression and classification within 50 LOC.
Stars: ✭ 36 (-60%)
Mutual labels:  portable
relative-path
Portable relative UTF-8 paths for Rust.
Stars: ✭ 54 (-40%)
Mutual labels:  portable
detect-libc
Node.js module to detect details of the C standard library (libc) implementation provided by a given Linux system
Stars: ✭ 33 (-63.33%)
Mutual labels:  libc
streamlink-portable
A script to build a portable version of Streamlink for Windows
Stars: ✭ 70 (-22.22%)
Mutual labels:  portable
nimodpi
Oracle ODPI-C wrapper for Nim
Stars: ✭ 17 (-81.11%)
Mutual labels:  nim-lang
LatexDSL
A mini DSL to generate LaTeX from Nim
Stars: ✭ 22 (-75.56%)
Mutual labels:  nim-lang

Cosmopolitan Libc for Nim

This is a simple example to show how can you use Cosmopolitan with Nim. Directory structure:

  • stubs - contains empty include files that Nim expects to be available. Cosmopolitan provides all of these in a single include file.

  • hello.nim - Nim file that we want to compile

  • nim.cfg - Neccessary configuration file to set all the C compiler options to the ones required by Cosmopolitan.

First you need to get the Cosmopolitan itself - simply go to the downloads and grab the latest release (0.2 as of 03-03-2021). Then extract it into the cosmopolitan folder so that it looks something like this:

cosmopolitan/
├── ape.lds
├── ape.o
├── cosmopolitan.a
├── cosmopolitan.h
└── crt.o

Now you can actually compile the first example with:

# Compile an ELF binary
nim c -d:danger --opt:size -o:hello.elf hello.nim

# Get the actual portable executable
objcopy -SO binary hello.elf hello.com

If you import some other stdlib modules and the compilation fails, first check if the C compiler is complaining about missing headers - if so, just add that header into the stubs directory (just create an empty file with the right directory hierarchy), and it'll probably work :P

Apart from hello.nim, this repo also has gethttp.nim and asyncserv.nim. To compile them you need to apply the asyncserv.diff patch to your local Nim installation. This is also pretty simple:

cd nimGitDir
git apply /path/to/cosmonim/asyncserv.diff 

Then you can compile those examples as usual.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].