jac-native-shared

Builds C-ABI shared libraries from Jac code for FFI consumption.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-native-shared-nihalnihalani
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-native-shared
Source: https://github.com/nihalnihalani/jachacks-sf-2026/tree/main/plugins/jac-codex/skills/jac-native-shared
Command: npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-native-shared-nihalnihalani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Exposing Jac code to non-Jac hosts like C, C++, Rust, Go, or Python normally requires manual FFI plumbing and external toolchains. This Skill documents how jac nacompile --shared packages a native Jac module into a loadable .so, .dylib, or .dll with no gcc or linker invocation. ## Core Features & Use Cases - Export surface control: Only :pub symbols land in the export table, with automatic global initialization on load and no entry point required. - Opaque handle ABI: Scalars and strings cross by value while Jac objects cross as opaque void* handles managed via jac_retain/jac_release. - Cross-compilation: Build Mach-O .dylib or PE .dll artifacts from any host with --target macos or --target windows. - Use Case: Compile a Jac math library into libmathlib.so, then call its exported functions from Python ctypes or link it into a C application with gcc. ## Quick Start Compile my Jac module into a shared library and show me how to call its exported functions from Python ctypes.

Frequently Asked Questions about jac-native-shared

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a shared library from Jac code?▼

Run `jac nacompile mathlib.jac --shared` to produce libmathlib.so for the host platform. Add `--target macos` or `--target windows` to cross-build a .dylib or .dll without needing gcc, ld, or lld.

How do I call Jac shared library functions from Python?▼

Load the library with ctypes.CDLL, set restype and argtypes for each exported function, then call them directly. Jac objects return as opaque void* handles that you pass back into other exported functions and free with jac_release.

Which Jac symbols are exported from a shared library?▼

Only symbols marked `:pub` appear in the export table; everything else stays internal. Methods on objects are not exported, so wrap them in `:pub` free functions, and a build with zero `:pub` symbols fails.

Why does an exported Jac global read as 0 when linked from C?▼

Linking an exported global directly as `extern long counter;` reads 0 because copy relocations are unsupported by the emitted .so. Read globals via dlsym or ctypes.in_dll, or expose a `:pub` accessor function instead.

Can I cross-build a Windows DLL or macOS dylib from Linux?▼

Yes, `jac nacompile --shared --target windows` or `--target macos` emits structurally valid PE or Mach-O files from any host. However, you can only load-test the artifact on the matching operating system.