Are there any efforts to create a package manager for C++?

C++Package Managers

C++ Problem Overview


One of my biggest frustrations with my favorite language is the effort it takes to get different libraries working for together under one unified development environment. My biggest wish is to just be able to tell my IDE, or whatever, that I need a certain library, and it takes care of downloading it, compiling it(if necessary), installing it, then setting up the include and library paths.

What I want is this, but for C++. I would prefer if it works with Visual Studio, but gcc is okay too. Or if it is it's own separate system, that's fine too. It does, however, have to work in Windows.

What promising projects are out there to solve this problem?

C++ Solutions


Solution 1 - C++

Have you considered Git as a package manager? I've been using git submodules for dependencies and sub-dependencies and combined with free git hosting services, the idea is quite powerful.

Just go into your git project,

git submodule add git://somehosting.com/you/package.git
git submodule init package
git submodule update package
cd package && ./configure --stuff && make && cd ..

To select particular dependency versions,

cd package && git checkout v3.2 && cd .. && git add package/
git commit -am "package version 3.2 pinned" && git push

Now you've pinned your package dependency to a particular tag and saved your settings to your project repository. Next time someone does:

git pull && git submodule update

Their package dependency will also be pinned to v3.2.

Some package management systems also feature signed packages. Git allows you to GPG sign your tags and lets people verify it by adding your public key to their keyring.

So we have package downloading, dependency versions and we can emulate "package signing". One missing part is pre-built binaries which, in my opinion isn't an absolute necessity. Another missing part is global package management. You will have to manually manage each git repository when a dependency of a dependency gets updated.

Solution 2 - C++

The answer is to use Conda for packaging/dependency management and whatever tool you like for building (I use CMake).

Check it out here:

http://conda.pydata.org/

Conda is similar to package managers like apt-get, yum, nuget, etc, but with several important advantages:

  1. fully cross-platform (currently Linux, Windows, and OSX, but other platforms can be added easily)

  2. does NOT require root access to use. In fact, doesn't care about your system packages at all. It's similar to building out an entire stack (down to libc if you want) in your homedir, except somebody already built them for you. This magic is achieved by making packages relocatable.

  3. you can maintain as many different environments as you want side-by-side. Does one of your applications require python 2.7.6, but another one needs python 2.7.4? No problem - they can coexist in peace

  4. you will never again be forced to maintain separate builds for the various Linux distros. A properly-constructed Conda environment will work on any of them. Don't forget other platforms as well (e.g. Windows and OSX)!

  5. you are no longer married to versions of libraries that were decided FOR you by a system or an IT department. For example, I was forced to work on RHEL5 nodes. The Python there is a joke (over 10 years old now). By using Conda I bypassed that pain and was able to work on any version of Python that I wanted without affecting anybody else.

  6. environments can be zipped up into "installers" for distribution.

  7. you can maintain your own private repository behind your firewall for proprietary libraries. The public centralized repository is called Binstar. Your dependencies can come from either (or both).

Many people mistakenly believe that Conda is a Python-only system, but actually Conda was created for native packaging (it is language agnostic). It has a huge Python presence simply because its original motivation was to overcome terrible native library support in Python's other packaging system (pip + pypi).

The only problem with Conda currently is that Binstar (the central repository) doesn't have every package yet. You will definitely encounter missing libraries that you want - but that's easy to fix: you can build whatever package you like yourself and push it to Binstar. I've had to do this for dozens of native libraries. It works quite well.

I'll never go back to system dependency managers when developing C++ code.

Solution 3 - C++

This is unlikely to occur simply because differing C++ libraries often use VASTLY different build systems. Autoconf, scons, make, MSBuild, VCBuild, Boost Jam, CMake, NMake, and QMake are examples. Additionally, a lot of C and C++ developers generate code with tools like Yacc and Bison.

Maven and NuGet work the way they do because they support ecosystems with (relatively) little variation in build tools. Ant in Maven's case, MSBuild in NuGet's case. Building a similar system to work with the vast array of C++ build systems in use would be infeasible and impractical (given the seeming lack of demand for such systems).

Solution 4 - C++

As of NuGet 2.5, NuGet supports native projects. However, making the package by hand is pretty complex, so they suggest using CoApp's Powershell Tools for NuGet (documentation here). Using these tools, you can now host your C/C++ packages on NuGet.

Solution 5 - C++

If you are using MinGW, there is already a package manager similar to apt-get / aptitude which does what you want: mingw-get

It behaves similar to Debian's apt-get/aptitude. Among the packages that are already included you can find expat, libxml2, zlib, pthread etc.

Obviously, you will need a copy of MinGW to start working with it.

Solution 6 - C++

I've been working on a cross-platform and cross-architecture distributed package manager. All packages are installed in the project directory (a bit like how nodejs works). It is a work in progress.

Solution 7 - C++

There is Daveed's module proposal, which didn’t make it into C++0x.

Solution 8 - C++

ryppl seems to be doing what you required and more, cross platform:

> Our mission [is] to create the conditions for a portable, modular C++ software ecosystem

Already starred them on GitHub: https://github.com/ryppl/ryppl

Solution 9 - C++

There is CoApp, which seems to have Microsoft's support.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBenjamin LindleyView Question on Stackoverflow
Solution 1 - C++nurettinView Answer on Stackoverflow
Solution 2 - C++Spencer StirlingView Answer on Stackoverflow
Solution 3 - C++Billy ONealView Answer on Stackoverflow
Solution 4 - C++JKorView Answer on Stackoverflow
Solution 5 - C++EranView Answer on Stackoverflow
Solution 6 - C++ioquatixView Answer on Stackoverflow
Solution 7 - C++Cheers and hth. - AlfView Answer on Stackoverflow
Solution 8 - C++Ciro Santilli Путлер Капут 六四事View Answer on Stackoverflow
Solution 9 - C++FerruccioView Answer on Stackoverflow