Logo von Nim C Bindings

Nim C Bindings

Community
planetis-m
nim-c-bindings

Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and CI/release workflows. Use when wrapping a C dependency, fixing Nim FFI build issues, or setting up cross-platform GitHub Actions for a Nim native library project.

Übersicht

Herausgeberplanetis-m
Repositoryskills
Skill-Namenim-c-bindings
Sterne
66
Forks
7
Mitgelieferte Dateien
3
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • Mitgelieferte Dateien: 3

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

    Von planetis-m auf GitHub veröffentlicht. Prüfen Sie vor der Installation die Quelldateien.

Installation

Installieren Sie den KI-Skill Nim C Bindings in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner. Dabei liest die App SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/planetis-m/skills/tree/master/nim-c-bindings
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill hinzufügen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format unterstützt, kann diesen Skill nutzen. Kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/planetis-m/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/nim-c-bindings .claude/skills/nim-c-bindings
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Nim C Bindings in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Nim C Bindings automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Nim C Bindings nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Schlüsseln.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

Nim C Bindings & CI

Rules

Binding Fundamentals

  • Use importc with cdecl for C APIs unless the library explicitly requires a different calling convention (e.g., stdcall).
  • Represent opaque C handles as type Name = ptr object types. Use incompleteStruct for partial/opaque structs to avoid size/layout mismatches.
  • Use {.bycopy.} on structs that Nim must pass by value to C.
  • Declare the C header in the binding when the compiler needs the C definitions for compilation, for example header: "foo.h".
  • Use {.push callconv: cdecl, importc.} blocks when many declarations share the same convention.
  • Match C storage with Nim's C-compatible types such as cint, cuint, clong, culong, clonglong, csize_t, cfloat, cdouble, cstring, and pointer types.
  • Preserve the complete field order for concrete structs passed or returned by value.
  • When the requested deliverable is a raw binding, import C symbols directly. Put ergonomic aliases and conversions in a separate wrapper layer.

Linking

  • System libraries: link with -l<name> only. Do not hardcode -L paths — the OS toolchain already knows where system libs live.
  • Local/third-party libraries: add both -L<dir> and -l<name> (or .lib/.dll.lib paths on Windows MSVC).
  • Use repository-relative paths for vendored dependencies, for example third_party/libfoo, to keep builds hermetic.
  • Distinguish linker-resolved imports from Nim runtime dynlib imports. header supplies declarations for generated C; a runtime-only dynlib proc should not also use header.

Runtime Library Resolution

  • Vendored/local shared libs: colocate the .so/.dylib/.dll next to the executable. Do not rely on environment variables for discovery.
  • System-installed libs: do not copy DLLs/shared libs next to the executable. Rely on the platform's normal system loader configuration. Use environment variables only as temporary overrides.
  • On Linux, add rpath $ORIGIN only when loading colocated shared libs. From the shell, pass --passL:"-Wl,-rpath,\$ORIGIN". In Nim source, use {.passL: "-Wl,-rpath,\\$ORIGIN".}.
  • Do not use build-tree-only rpaths or absolute paths to non-system shared libraries.

Platform Rules

PlatformToolchainDepsLink flagsRuntime
LinuxSystem GCC/Clangapt-l<name> or -L<dir> -l<name>Colocate local .so; rpath $ORIGIN if needed
macOSApple ClangHomebrewstaticExec("brew --prefix") for -I/-LColocate local .dylib
WindowsMSVC (--cc:vcc)vcpkg only.lib/.dll.lib full pathsColocate .dll next to .exe
  • On macOS, resolve include/link paths via staticExec("brew --prefix <formula>").
  • On Windows, use MSVC via --cc:vcc. Use vcpkg only — avoid Chocolatey and MSYS2. Never mix toolchains.
  • On Windows, do not rely on implicit -l<name> for MSVC. Use explicit .lib or .dll.lib paths.
  • On Windows CI, export VCPKG_ROOT to the installed triplet root and prepend its bin to PATH.

CI & Release

  • CI is the authoritative spec for supported platforms, toolchains, and flags. Local workflows must be compatible with CI.
  • Keep test builds simple: compile, then run, with minimal environment mutation.
  • Align the local toolchain with CI (e.g., MSVC + vcpkg x64-windows-release with --cc:vcc).
  • Use the reference workflows as starting points — references/ci.yml for validation, references/release.yml for tagged releases.

Verification

  • Compile against the real header and call the real C implementation.
  • Exercise concrete structs passed and returned by value. Compare Nim layout with C sizeof and offsetof probes when layout is in doubt.
  • Test bundled shared libraries after copying the executable and library into a clean directory.
  • For dynlib, verify runtime loading without also linking that library.

Workflow

  1. Identify the C API. Determine calling convention, opaque vs value types, and ownership.
  2. Write bindings. Use importc, correct calling convention, incompleteStruct for opaque types, bycopy for value types. Add header pragma.
  3. Set up linking. System libs: -l only. Local libs: -L + -l with repo-relative paths. Windows: explicit .lib paths.
  4. Handle runtime. Colocate local shared libs. For system-installed libs, rely on the normal loader search path. Add rpath $ORIGIN on Linux only for colocated local libs.
  5. Verify the ABI. Run a real C round trip for the types and calls used by the binding.
  6. Add CI. Copy references/ci.yml, adapt placeholders (<package>, <src/main.nim>, dependency lists).
  7. Add release. Copy references/release.yml, adapt placeholders, configure draft releases.
  8. Test locally, then push. Verify the build works locally with the same flags CI uses.

Common Mistakes

MistakeWhy it's wrong
Hardcoding -L paths for system librariesOS toolchain already knows where they are; breaks portability
Mixing MSVC + MSYS2/MinGW on WindowsIncompatible ABIs, linker errors, runtime crashes
Using implicit -l<name> with MSVCMSVC doesn't resolve libs the same way GCC does; use explicit .lib paths
Relying on env vars for vendored shared libsFragile across machines; colocate instead
Build-tree-only rpathsBreaks when the binary moves; use $ORIGIN for colocated libs
Guessing Windows dependency pathsNon-deterministic; use vcpkg with known install roots
Compiling C sources into the executable when the task requires an existing shared libraryBypasses shared-library link and relocation behavior
Adding Nim-bodied wrappers to a requested raw binding surfaceHides whether the C API was imported directly and changes the requested layer

References

  • references/raw_binding.md — Mapping an opaque handle and by-value C struct.
  • references/ci.yml — Building a C-dependent project on Linux, macOS, and Windows with Nim, Atlas, and vcpkg.
  • references/release.yml — Publishing tagged cross-platform archives in a draft release.

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill Nim C Bindings?

Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and CI/release workflows. Use when wrapping a C dependency, fixing Nim FFI build issues, or setting up cross-platform GitHub Actions for a Nim native library project.

Warum Nim C Bindings in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Nim C Bindings besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Nim C Bindings in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/planetis-m/skills/tree/master/nim-c-bindings ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Nim C Bindings nutzen?

Jedes Modell, das Sie mit TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Nim C Bindings verwenden?

So viele Sie möchten. In TypingMind können Sie Nim C Bindings mit jedem Modell verwenden, das Skills unterstützt, etwa mit GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama. Dabei nutzen Sie Ihre eigenen API-Schlüssel.

Ist der KI-Skill Nim C Bindings kostenlos?

Der Skill wird von planetis-m auf GitHub veröffentlicht. Prüfen Sie im Repository, ob dort Lizenzbedingungen angegeben sind. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: Die Datei SKILL.md enthält den Namen und die Beschreibung des Skills. Hinzu kommen bei Bedarf Skripte, Vorlagen oder Referenzdateien für das Modell. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und kommen daher ohne Server, API-Schlüssel und Laufzeitumgebung aus. Sie funktionieren mit jedem Modell.

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇