npm 中文文档 npm 中文文档
指南
npmjs.com (opens new window)
指南
npmjs.com (opens new window)
  • 快速入门

    • npm 是什么?
    • npm 安装和更新
    • npm 防止权限错误
    • npm package.json 文件
    • npm 安装包
    • npm 更新包
    • npm 卸载包
    • npm 创建 Node.js 模块
    • npm 发布和更新包
    • npm 使用语义化版本
    • npm 使用 Dist-tags 标记包
    • npm 包和模块的了解
  • 命令行
  • 配置 npm

clib(1)


Package manager for the C programming language.

Installation


Expects libcurl to be installed and linkable.

With homebrew :

  1. ``` shell
  2. $ brew install clib
  3. ```

Or MacPorts :

  1. ``` shell
  2. $ sudo port selfupdate
  3. $ sudo port install clib
  4. ```

With git:

  1. ``` shell
  2. $ git clone https://github.com/clibs/clib.git /tmp/clib
  3. $ cd /tmp/clib
  4. $ make install
  5. ```

Ubuntu:

  1. ``` shell
  2. # install libcurl
  3. $ sudo apt-get install libcurl4-gnutls-dev -qq
  4. # clone
  5. $ git clone https://github.com/clibs/clib.git /tmp/clib && cd /tmp/clib
  6. # build
  7. $ make
  8. # put on path
  9. $ sudo make install
  10. ```

About


Basically the lazy-man's copy/paste promoting smaller C utilities, also serving as a nice way to discover these sort of libraries. From my experience C libraries are scattered all over the web and discovery is relatively poor. The footprint of these libraries is usually quite large and unfocused. The goal of clibs is to provide stand-alone "micro" C libraries for developers to quickly install without coupling to large frameworks.

You should use clib(1) to fetch these files for you and check them into your repository, the end-user and contributors should not require having clib(1) installed. This allows clib(1) to fit into any new or existing C workflow without friction.

The wiki listing of packages acts as the "registry" and populates the clib-search(1) results.

Usage


  1. ``` sh
  2.   clib <command> [options]

  3.   Options:

  4.     -h, --help     Output this message
  5.     -V, --version  Output version information

  6.   Commands:

  7.     init                 Start a new project
  8.     i, install [name...] Install one or more packages
  9.     up, update [name...] Update one or more packages
  10.     upgrade [version]    Upgrade clib to a specified or latest version\
  11.     configure [name...]  Configure one or more packages
  12.     build [name...]      Build one or more packages
  13.     search [query]       Search for packages
  14.     help <cmd>           Display help for cmd

  15. ```

More about the Command Line Interface here.

Examples


More examples and best practices at BEST_PRACTICE.md.

Install a few dependencies to ./deps :

  1. ``` shell
  2. $ clib install clibs/ms clibs/commander
  3. ```

Install them to ./src instead:

  1. ``` shell
  2. $ clib install clibs/ms clibs/commander -o src
  3. ```

When installing libraries from the clibs org you can omit the name:

  1. ``` shell
  2. $ clib install ms file hash
  3. ```

Install some executables:

  1. ``` shell
  2. $ clib install visionmedia/mon visionmedia/every visionmedia/watch
  3. ```

clib.json


Example of a clib.json explicitly listing the source:

  1. ``` json
  2. {
  3.   "name": "term",
  4.   "version": "0.0.1",
  5.   "repo": "clibs/term",
  6.   "description": "Terminal ansi escape goodies",
  7.   "keywords": ["terminal", "term", "tty", "ansi", "escape", "colors", "console"],
  8.   "license": "MIT",
  9.   "src": ["src/term.c", "src/term.h"]
  10. }
  11. ```

Example of a clib.json for an executable:

  1. ``` json
  2. {
  3.   "name": "mon",
  4.   "version": "1.1.1",
  5.   "repo": "visionmedia/mon",
  6.   "description": "Simple process monitoring",
  7.   "keywords": ["process", "monitoring", "monitor", "availability"],
  8.   "license": "MIT",
  9.   "install": "make install"
  10. }
  11. ```

See explanation of clib.json for more details.

Contributing


If you're interested in being part of this initiative let me know and I'll add you to the clibs organization so you can create repos here and contribute to existing ones.

If you have any issues, questions or suggestions, please open an issue here.

You can also find us on Gitter: https://gitter.im/clibs/clib

Also feel free to open a GitHub Discussion here.

Before committing to the repository, please run make commit-hook. This installs a commit hook which formats .c and .h files.

Articles


Introducing Clib - introduction to clib
The Advent of Clib: the C Package Manager - overview article about clib
Last Updated: 2023-07-09 20:15:34