Does C++ have a package manager like npm, pip, gem, etc? [closed]

Solution 1:

There seem to be a few though I've never used them.

dds https://github.com/vector-of-bool/dds

cpm http://www.cpm.rocks/

conan https://conan.io/

pacm http://sourcey.com/pacm/

spack https://spack.io

buckaroo http://buckaroo.pm

hunter https://github.com/ruslo/hunter

vcpkg https://github.com/Microsoft/vcpkg

Solution 2:

Conan is the clear winner today based on its 36+ GitHub contributors and the fact I found their Getting Started documentation to be easy enough to get working. It's MIT licensed too.

Conan's documentation even compares it to biicode which I was surprised wasn't mentioned in other answers, but biicode seems to be abandoned much like cpm.

pacm has some activity but is LGPL which may be an issue for some projects.

This builds on user3071643's answer, thanks!

Solution 3:

No, there certainly isn't an official package manager for C/C++, but I'll give you a few suggestions to hopefully make your days better.

First, I would suggest investigating CMake or GENie for ways of incorporating libraries in your build system in an extensible and cross-platform way. However, they both assume that you have libraries that are in an "easy to find" place or that they have the same build system as your project. There are ways to teach both how to find libraries that you need. All other solutions are platform specific.

If you have Node.js or Haxe in your project, then both npm and haxelib do have ways that you can use C++ (in a precompiled dll/so form) from JavaScript or Haxe respectively, but that's a big, and probably wrong, assumption that you'd be using Node.js or Haxe in a project that really needs the benefits that C/C++ can provide.

For the Microsoft world, I believe that NuGet has some C++ libraries, although it's limited in its platform support to Visual Studio, and probably Windows, but it probably best fits what you mean by "package system" given your examples (assuming that you meant that cpm was a C Package Manager in the way that npm is Node Package Manager).

For the Linux world, technically, rpm, yum, and apt-get do function as C/C++ development package managers just as much as a system package manager, but unlike npm, you must always install packages globally, but given that your app, if it's a Linux app, would likely be in a package on one or more of these managers, and packages have a dependency list embedded in them, it's not much of a problem.

For the macOS/iOS world there's CocoaPods, but, like, NuGet, you're locked-in to the Apple platform. There is always MacPorts, if you are happy with the Linux-style package manager as a dev package manager, as described in the previous paragraph.

I want this npm, local install, sort of functionality cross-platform as well, but since C/C++ is used on so many platforms (all of them?), and C/C++ programmers, like myself, tend to roll their own... everything, which keeps us all (unnecessarily?) busy, there hasn't been much of a push for making such a project, which is a shame. Perhaps, you should make one? It would certainly make my days better.

UPDATE

Conan is the C/C++ package manager that we've all been wanting. It has both local and global servers, so it's good for both business and open source packages. It's young, and its global repository doesn't have very many packages. We should all work to add packages to it!

UPDATE 2

I have found that vcpkg has been very useful for Windows and Android. If you can't get over the fact that Conan.io is written in Python, then it might be worth a look.

Also, although it mandates that you use it for yourself and all of your dependencies, I believe that Build 2 should be the ultimate winner in a few years, but as of the time of writing, it's still upcoming.