cangjie-ffi-build

Build C/FFI interoperability projects in the Cangjie ecosystem with cjc and cjpm.

2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-ffi-build-zhenzhizhi12
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-ffi-build
Source: https://github.com/zhenzhizhi12/NexusAgent/tree/main/.opencode/skills/common-skill-l1/ffi_build
Command: npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-ffi-build-zhenzhizhi12

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance on configuring, building, and running C interoperability projects for the Cangjie language, including handling dynamic and static libraries across different platforms.

Core Features & Use Cases

  • Platform-Specific Library Naming: Details naming conventions for shared and static libraries on Linux, macOS, and Windows.
  • Compiler Linker Options: Explains essential cjc compiler flags like -L and -l for library path and linking.
  • Direct Compilation Examples: Provides step-by-step shell commands for compiling C code into libraries and linking them with Cangjie code on various operating systems.
  • cjpm Project Integration: Guides users on configuring cjpm.toml for FFI dependencies and building/running projects.
  • Security Best Practices: Recommends compiler and linker flags for enhanced security (e.g., -fstack-protector-all, -z noexecstack).

Quick Start

Use the cangjie-ffi-build skill to learn how to compile a C shared library named 'native' and link it with a Cangjie main file named 'main.cj' on Linux.

Frequently Asked Questions about cangjie-ffi-build

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

FAQPage Schema
How do I build C interoperability projects in Cangjie using cjc?

To build C interoperability projects in Cangjie, compile C code into shared or static libraries, then link them with Cangjie code using the `cjc` compiler flags `-L` for library paths and `-l` for linking, following platform-specific naming conventions for Linux, macOS, and Windows.

How do I configure cjpm.toml for FFI dependencies in a Cangjie project?

Configuring FFI dependencies in `cjpm.toml` involves specifying library paths and linking options within the configuration file, enabling the `cjpm` package manager to automatically resolve and build C interoperability projects alongside Cangjie source code.

What are the platform-specific naming conventions for shared and static libraries in Cangjie FFI?

Platform-specific library naming conventions for Cangjie FFI dictate distinct prefixes and suffixes for shared and static libraries across Linux, macOS, and Windows, ensuring the `cjc` compiler and `cjpm` linker can correctly locate and link the required binaries during compilation.

Which compiler and linker flags should I use for security hardening in Cangjie FFI builds?

For security hardening in Cangjie FFI builds, apply compiler and linker flags such as `-fstack-protector-all` to protect stack memory and `-z noexecstack` to enforce non-executable stacks, mitigating potential vulnerabilities during C and Cangjie interoperability compilation.

Can I compile C shared libraries and link them with Cangjie main files on Linux?

Yes, you can compile C shared libraries and link them with Cangjie main files on Linux by executing direct shell commands to build the C code into a library, then using `cjc` with appropriate linker options to integrate it with a Cangjie main file.