DEV Community

Noah11012
Noah11012

Posted on

CLibs: A Package Manager for C

Many modern-day languages like Python and Rust have their own standard package managers that help with installing dependencies for projects. C never had one... until now.

CLibs is a package manager for C that is focused on "micro" libraries. This means all libraries you can install with CLibs are lightweight, fast, and have a small footprint in your overall projects.

Getting Started

To install CLibs, enter in the following commands into your preferred terminal:

git clone https://github.com/clibs/clib.git /tmp/clib
cd /tmp/clib
make
sudo make install

Make sure you have the developer version of libcurl installed on your system.

Searching for the package you need is easy.

clib search [package-name]

Installing is also easy.

clib install <user>/<repo>

You can install more than one package at a time.

Integrating with CLibs

Maybe you're convinced that CLibs is the package manager for C and you would like to get your project to become supported by CLibs.

The way CLibs was created in mind, this is extremely simple to do. Create a package.json file at the root directory of your project. A template would like something like the following:

{
  "name": "term",
  "version": "0.0.1",
  "repo": "clibs/term",
  "description": "Terminal ansi escape goodies",
  "keywords": ["terminal", "term", "tty", "ansi", "escape", "colors", "console"],
  "license": "MIT",
  "src": ["src/term.c", "src/term.h"]
}

For more details on package.json: https://github.com/clibs/clib/wiki/Explanation-of-package.json

Now that you know a package manager exists for C, will you add support for CLibs?

Github repository for CLibs: https://github.com/clibs/clib

Top comments (18)

Collapse
 
tobiassn profile image
Tobias SN

Not to be mean or harsh, but can’t one just use a regular package manager?

Collapse
 
noah11012 profile image
Noah11012

I'm not sure what you mean by a "regular" package manager. If you mean the package manager provided by a Linux distribution like Linux Mint or Manjaro, then yes, you can use that if you prefer.

However, creating packages that are Debian based (not sure how to create packages for Manjaro) takes a lot more work than simply adding a package.json file to your project. It's similar to spirit to using npm when creating/working on JS projects.

Collapse
 
tobiassn profile image
Tobias SN

Yes, it's a bit harder to package for Debian, but it's a one-time job, and you don't have to edit anything related to the packaging pipeline to add or remove files, as it's completely independent of one's build tools.

Thread Thread
 
noah11012 profile image
Noah11012

That is true, but CLibs is focused on small C libraries; typically no more than a few files. So, adding/removing files from the package.json is not a frequent issue.

If your library is much bigger than a few files, that I would recommend going with a regular package manager.

Thread Thread
 
tobiassn profile image
Tobias SN

But then what’s the advantage with small libraries?

Thread Thread
 
noah11012 profile image
Noah11012

Small libraries are lightweight because of their small footprint. You're only using what you need and not having it coupled with a framework or part of a bigger library.

Of course, bigger libraries have their place in the world of programming, but sometimes one just needs a micro library to do the job.

Thread Thread
 
tobiassn profile image
Tobias SN

No, I meant what advantage does one get by having people install one’s package through CLibs?

Thread Thread
 
noah11012 profile image
Noah11012

A couple of reasons: the creator of CLibs states that libraries for C are scattered all over the web and CLibs can help them discover these types of libraries for themselves.

CLibs isn't required to be installed for the end users or contributors. This allows CLibs to seamlessly integrate with any new or existing projects.

Thread Thread
 
tobiassn profile image
Tobias SN

And how does it help people discover libraries any more than a simple Google search?

Thread Thread
 
noah11012 profile image
Noah11012

Again, CLibs helps to discover micro-libraries.

Thread Thread
 
tobiassn profile image
Tobias SN

You didn’t answer my question.

Thread Thread
 
noah11012 profile image
Noah11012

The author the library expressed the sentiment that the discovery of C libraries is "relatively poor" and sometimes they are unfocused and have a bigger than necessary footprint.

The point of CLibs is to use micro-libraries that meet your project's needs. Yes, a simple Google search might suffice for a bigger project, but for the search of smaller libraries, it might not.

Personally, I don't use CLibs, mainly because I only have one project in C. The reason I made this post is so that other people would know about and perhaps some of them would find a use for it.

Thread Thread
 
tobiassn profile image
Tobias SN

Still, what does it do to make discovery easier?

Thread Thread
 
noah11012 profile image
Noah11012

Just by using clib search [package-name]. Sure, you could Google search it, but, it might not come up.

Thread Thread
 
tobiassn profile image
Tobias SN

But you still need to know about the library to do that, so it’s more of a “Can I install this through CLibs?” thing.

Thread Thread
 
noah11012 profile image
Noah11012

Sure. If you want to, Google can be a great place to find certain libraries and for others, it might not be.

There's nothing wrong with wanting to use Google for this purpose, it's just that CLibs can offer another channel for finding useful libraries.

Thread Thread
 
tobiassn profile image
Tobias SN

Now you’re basically just repeating yourself.

Thread Thread
 
noah11012 profile image
Noah11012

Sorry, but that's all I have to say in this discussion. Use Google if you want and CLibs for an extra avenue for finding libraries.