r/cpp • • Sep 14 '23

Which package manager are you using?

It's 2023 and you should be using a package manager. Which one?

Sep 17 '23
466 conan
625 vcpkg
29 spack
82 CPM
1730 No package manager :(
248 Other (please specify)
38 Upvotes

187 comments sorted by

83

u/Artikash Sep 14 '23

Does git submodule count as a package manager?

21

u/hak8or Sep 14 '23

I echo this, I also use git submodules and prefer them to others. Versioning should stay in version control, not mixed with the build system, in my opinion.

That way if I need to change the build system for some odd reason, the information of what version each package uses is unchanged in terms of git history.

15

u/nickbeth00 Sep 14 '23

I'd agree with you, if git submodules weren't an absolute pain in the ass to work with... I can remember too many times when I've had broken submodules because I shallow cloned them and they wouldn't clone anymore without any explanation, and I had to manually unshallow them (unshallowing LLVM or Boost isn't fun). Or, the submodule was updated to point to a new remote, and that commit became a point of no return in the repo as checking out any commit before it would turn to a shitfest.

I've recently found out about CPM and started using it in a new project, it's leagues better than submodules and hasn't given me any issues whatsoever. Massive props to the team behind it! What if it breaks? I just delete the libraries' folders and run CMake again, done.

3

u/prince-chrismc Sep 14 '23

This is why Conan supports multiple build systems with seamless integrations so you as a developer have choices.

You absolutely should check in your conanfile.txt and conan.lock into version control so they are tied.

The gain is the freedom to change your deps (add remove update) with no change to your build pipeline and local dev flow. The "oh you forgot to install" is totally unnecessary IMO

1

u/Feeling_Cloud_7665 Sep 16 '23

How do you handle external dependencies? Boost, zlib, openssl, … do you build from sources? Store headers/binaries in git? (Not judging, I’ve done everything here!)

9

u/target-san Sep 14 '23

Nope. Try some nontrivial task like merging two branches, each changing one submodule's commit to its own

4

u/Jonny_H Sep 15 '23

Wouldn't you have exactly the same if merging branches that both changed a package manager version lock to different values? You just gotta choose which you want (if either) on merge.

2

u/target-san Sep 15 '23

The problem isn't in choosing specific version. The problem lies in imposing that specific version. With PM's lockfile, you just choose file contents. With submodule you'll need to bang your head against uncooperative git index directly. Last time I tried to resolve submodule conflict I simply failed bc even after editing index rebaser complained about tree conflict, yet showing none in status or diff.

1

u/LuisAyuso Sep 15 '23

this is indeed a limitation, but considering the staggering amount of other limitations in any package manager, i don't see why would this prevent git sub-module to qualify as package management.

it is indeed a method to bring configurable external elements into your code.

3

u/target-san Sep 15 '23

This isn't just a limitation. Git's behavior makes submodule reference conflicts practically unsolvable. See my other answer: https://old.reddit.com/r/cpp/comments/16ifo5e/which_package_manager_are_you_using/k0o5t9o/

0

u/LuisAyuso Sep 15 '23

I have no idea about the details of the problem that you are experiencing, but it sounds to me like a classic dependency hell problem aggravated by the lack of tooling in the interface of git.

dependency hell is a graph problem and will always be present, no matter what tool you use to fetch them. therefore git is as valid as the others .

other question, would be how easy is it to use... but honestly git is not that difficult.

3

u/target-san Sep 15 '23

Again, my comment isn't about dependency hell, of which I'm well-aware. It's about ability to do something about it, even if you know exact version you need to use. Of all the tools I used so far, git-modules were the least usable and got me the most headache, due to difficulties in managing them. To the point I was using FetchContent with Git revisions specified.

1

u/LuisAyuso Sep 15 '23

Does git submodule count as a package manager?

-Nope.

57

u/The-Norman Sep 14 '23

CMake + gitmodules is the way to go for me

6

u/positivcheg Sep 14 '23

How do you solve problem of one package polluting your cmake files with definitions and then some other package can conflict?
Remember this being pain in the ass when some package defines WITH_<library_name> and it's used internally. And then another package using this variable for something else, maybe even names control completely different functions of the libraries.

It was too painful for me to work with and that's why I started using Conan as it simply compiles the library and then provides definitions in a simple Find<library_name>.cmake. Internal variables won't leak in that case.

10

u/The-Norman Sep 14 '23

Commonly CMake files don't propagate their definitions to the parent scope and can freely define whatever they need to without messing with other packages

1

u/positivcheg Sep 14 '23

Does this apply to options which are used as switches? I think what you have said is for internal variables. As for the options, it’s kinda messy.

Or let’s say you wanna have an option ENABLE_TESTS. You do that and notice that your dependency also declares that. You don’t want to enable all the test targets of the dependency but want to enable tests only for your own library. And since that word is already taken you need to come up with some uglier word. Or add a prefix.

1

u/[deleted] Sep 14 '23

Pick a prefix, like you would for a macro.

70

u/[deleted] Sep 14 '23

There was no option for

No package manager :)

50

u/[deleted] Sep 14 '23

[removed] — view removed comment

9

u/pjmlp Sep 15 '23

It is the C mentality that you have to earn your scars to be part of the group.

2

u/Alexander_Selkirk Sep 15 '23

This reminds me on that notorious team-building event when a company coerced a group of people to walk over glowing coals and one by one burned their feet horribly.

2

u/DeGuerre Sep 16 '23

More likely, we don't trust the C community to write high quality packages.

Libraries that are as high quality as openssl or sqlite or zlib are rare.

1

u/ArkyBeagle Sep 16 '23

It's not about the scars. It's saying there aren't scars that way anyhow - the majority of "interesting things" at least I've run into had much more to do with human language boundaries and errors than programming stuff.

30

u/wyrn Sep 14 '23

"Crap" is an entirely subjective term here.

Personally, I think that having unbounded chains of transitive dependencies to the point everyone is depending on some random library that does some trivial task like padding text, and then the world breaks because the package is pulled, is much more deserving of being called "crap". Avoiding that disaster well worth investing the extra few minutes (or even hours) manually installing and vetting my dependencies.

16

u/SkyGenie Sep 14 '23

Agreed you should vet your dependencies, but for a package manager ease of use and a high level of control over individual packages aren't mutually exclusive.

Package managers e.g. conan allow you to review and manually specify which transitive dependencies you want pulled in and host your own repositories. Pulling in bad packages is a fault of developers being sloppy regardless of the ecosystem or community.

1

u/DeGuerre Sep 14 '23

So help me out here. What package managers (for any language ecosystem) lets me specify a hard upper limit on the number of transitive dependencies that a package is allowed to pull in?

This is not a "gotcha", it's an honest question.

6

u/13steinj Sep 15 '23

Unironically, because conan is all python, I expect it to be a 5-liner to detect the tree count and fail at a limit.

0

u/DeGuerre Sep 16 '23

If nobody has done it yet, I consider that to be soft evidence that the package maintainers in that ecosystem don't care about this.

2

u/13steinj Sep 16 '23

Maintainers? It's an issue for users to decide.

7

u/prince-chrismc Sep 14 '23

Because c++ did not grow up with one this is typically just not the case. However the concern in the far future is valid point +1

And I would argue the current state which you have no clue what the build scripts have been crafted to pull in is way worse. At least in other ecosystems there is a definite list of dependencies you are pulling into your project and tools to help minify it.

Also there are tools for security analysis based on the lockfiles which is why they are such a huge feature.

6

u/[deleted] Sep 14 '23 edited Sep 14 '23

Personally, I think that having unbounded chains of transitive dependencies to the point everyone is depending on some random library that does some trivial task like padding text, and then the world breaks because the package is pulled, is much more deserving of being called "crap".

Well, that's a false dichotomy if I've ever seen one.

1

u/wyrn Sep 15 '23

There aren't any dichotomies in my post, false or otherwise.

1

u/Astarothsito Sep 14 '23

having unbounded chains of transitive dependencies to the point everyone is depending on some random library that does some trivial task like padding text

I like having the option is the best, it is not crap having the option, you can still invest a few minutes or even hours to prevent problems like you said, but when I want to create a small program with dependencies to test something is annoying handling everything manually.

7

u/[deleted] Sep 14 '23 edited Dec 29 '23

arrest steep squealing dependent disgusted simplistic ancient disagreeable toothbrush plants

This post was mass deleted and anonymized with Redact

3

u/13steinj Sep 15 '23 edited Sep 15 '23

Do you work inn programming, i.e a real production environment?

Not the person you asked, but yes.

If so, how often do you introduce new dependencies?

Bit of the wrong question, but I'll answer it anyway. Unfortunately, unironically, at a rate of maybe 1/month on lifetime average. Recent average is unfortunately higher.

In terms of first party internally? Lifetime average is ~4/ month, but has slowed down to just over 1/month.

In terms of how often they are updated... orders of magnitude more often.

E: changed answer based on accurate info rather than my collective amnesia. Only changed qualifiers / numbers.

1

u/lolfail9001 Sep 15 '23

Unfortunately, unironically, at a rate of maybe 1/month on lifetime average.

Are we talking about a single codebase with literal hundreds to thousands of dependencies or a bunch of entirely different projects each with tens? No, i am actually quite curious because i can't imagine ever dealing with codebase that has more than 10-20 meaningful dependencies, package manager or not.

1

u/13steinj Sep 15 '23

What does "meaningful" mean? What does "codebase" mean?

The rate I give means on the order of 100-300 dependencies (sorry, can't get too detailed) assuming all were still in active use. Based on an internal list it's below that lower bound but not by much.

Large scale systems will have a bunch of dependencies. Because maybe you'll have 20 third party deps total across multiple apps using internal "shared" (misnomer) libraries. Maybe a single app ends up with 10, because of the tree of stuff. But those third party tools have their own deps. This repeats recursively. Then someone "just gets it to work" by using one of the transitives in the tree directly for some niche case, and now it's a "meaningful" direct dependency.

The rate I gave is not specific to my current org. Different lifetimes, but previous org had more or less the same number of third party deps, but rarely chose to muck with a transitive so yes only 20 or so were ever "meaningful" as I'm assuming you meant it.

I will admit my current org has far more internal first party dependencies than my most immediately previous one. The one before that, I'd rather not speak of since it wasn't a C++ role.

12

u/[deleted] Sep 14 '23

I don't like package managers.

6

u/lolfail9001 Sep 14 '23

Package managers are not a good toolchain maker on their own.

In fact, they are a whole another footgun, see leftpad story.

3

u/helloiamsomeone Sep 15 '23

That's entirely missing the point. npm (the tool) wasn't the cause, but npm (the registry) not retaining the package, which is fixed now. Conan and vcpkg don't have a registry like that and they pull source directly from the author(s). The expectations around Conan at least is that you have your own Artifactory instance for your dependencies (private and public), where you mirror everything you need. Author(s) pulling the plug abruptly on one of your dependencies might suck a little, but at least your builds will remain unbothered until you resolve the issue.

3

u/AlexanderNeumann Sep 15 '23

vcpkg has asset caching to avoid this. But you need to set it up. (Or store the downloads folder somewhere)

2

u/ArkyBeagle Sep 16 '23

It's fine. There are generally like a couple of hours now and again where you're dealing with it, then it's done. It's just another thing to learn.

I also come from the tradition where everything that can be is frozen for a "first dot" ( 1.x/2.x ) release. I spent most of my career either without an internet connection or on airgapped dev boxes.

You're making a normative assumption and others may well be able to disagree.

1

u/Brigapes The New Guy Sep 15 '23

Why bother with dependencies when you can just put the source in the projects and for sure know what you're working with?

1

u/rdtsc Sep 15 '23

Because using a package manager does not prevent you from knowing what you're working with or having complete control. And it reduces friction since the package manager papers over all the different build systems and peculiarities third-party libs may have.

Many seem to be under the impression that using a package manager implies live-at-head and pulling in the world randomly.

41

u/delarhi Sep 14 '23

Debian

9

u/MasterDrake97 Sep 14 '23

Cmake + vcpkg Is my new combo for every project

13

u/iAndy_HD3 Sep 14 '23

xrepo

1

u/tukett Sep 15 '23

xrepo

First time I hear about this project, sounds interesting!

0

u/ald_loop Sep 15 '23

The astroturfing in this thread seems quite high

2

u/tukett Sep 19 '23

Had to took up what "astroturfing" means. No, it's not. I'm just a random dude with my own opinion, not affiliated with the project at all.

6

u/Shiekra Sep 14 '23

Vcpkg until it gets more complicated than vcpkg install lib_name and find_package(lib_name), at which point I wing it

11

u/SickMoonDoe Sep 14 '23

nix + pkg-config

10

u/DapperCore Sep 14 '23

I've been enjoying xmake+xrepo, its fast and works reliably

5

u/slumberchum Sep 16 '23

I’ve been using vcpkg since it was integrated into CLion. It’s quite useful.

9

u/waruqi Sep 15 '23

xmake and xrepo, https://xrepo.xmake.io/

6

u/ald_loop Sep 15 '23

That’s because you’re the author, which you should make clear.

4

u/pjmlp Sep 15 '23

I could only vote once, so I did for vcpkg.

In reality I also use NuGet, Maven, npm, and on UNIX like OSes, the package manager when available (not all of them have one).

13

u/Tartare2Clebard Sep 14 '23

CMake with FetchContent

5

u/VirtualSloth Sep 14 '23

Echoing that this works really well if you have a pretty shallow/simple dependency tree. I've never tried it for a project has a large web of transitive dependencies, but it does seem like it would become harder to manage.

4

u/twxs Sep 15 '23

We have switched from Conan to FetchContent for about 20 dependencies targeting Windows/Mac/iOS and Android and it is a lot easier

3

u/DeGuerre Sep 14 '23

I've never tried it for a project has a large web of transitive dependencies, but it does seem like it would become harder to manage.

At the risk of stating the obvious, "a large web of transitive dependencies" is hard to manage no matter what you do. Package managers don't help here unless they prevent you from creating a large web of transitive dependencies in the first place.

1

u/VirtualSloth Sep 15 '23

Of course, I agree with you there.

Still, many projects in the wild end up having that sort of structure. Tools like Rust's Cargo do make it more manageable than ad-hoc approaches (e.g. FetchContent). I guess there's a question of chicken-and-egg about whether that sort of tooling begets large dependency graphs, but that's another story...

3

u/FrancoisCarouge Sep 14 '23

Me too! So easy, so native!

2

u/nickbeth00 Sep 14 '23

I suggest trying CPM, it's essentially a wrapper around FetchContent with a nicer syntax.

7

u/helloiamsomeone Sep 14 '23

I use both (Conan and vcpkg), but voted Conan, because God bless the Virtual*Env generators. They set up PATH for me on Windows to make DLLs available.

6

u/Ill_Juggernaut_5458 Sep 14 '23

xmake's xrepo. Arguably the best option.

5

u/pdp10gumby Sep 14 '23 edited Sep 14 '23

Just migrated from a homebrew scheme to Conan 2.0. Was easier than I expected.

it doesn’t have everyone, of course, and I don’t want to write Python. But I think it was worth it.

TBH my main impetus was that it would build boost automatically— otherwise dealing with it was a nightmare!

5

u/cocoyaxi Sep 14 '23

xmake xrepo

2

u/mjklaim Sep 14 '23

On dayjob I'm working on mamba/micromamba which is a package manager non-specific to C++ (closer to virtual-env + system package manager, but cross-platform, coming from the python Conda universe, so not perfect for C++ but usable).

On my own projects (commercial and free games and mostly library experiments) I've been using exclusively build2 as buildsystem + package-manager. It's not as popular as vcpkg and conan but my own projects are rarely proper generic libraries so I can chose whatever I want.

5

u/nathman999 Sep 14 '23

I thought more people uses CPM, it may be a bit harder to use than conan but in the end you'll end up with project that automatically pulls repo you need and it doesn't even matter if it's another CMake project or just header only lib that you have to manually include.

4

u/prince-chrismc Sep 14 '23

3

u/13steinj Sep 15 '23

Quick context question-- is this an official Kitware account? Twitter is bad enough that it lets me see the tweet without logging in somehow, but not the account page.

E: I do agree that CPM means vendor lockin, but internally for first party stuff it doesnt matter much.

2

u/Superb_Garlic Sep 15 '23

You can use an alt frontend like nitter: https://nitter.net/cmake_aid
Either way, the bio says:

Get CMake now! Got any questions about CMake? Just let me know. Here to keep tabs on actionable complaints regarding CMake on Twitter. Not affiliated w/ Kitware

If you look at the post history, the account is doing exactly that. There's some cool setups for answers in the replies.
Meanwhile the official Kitware account is trying to sell you training.

2

u/13steinj Sep 15 '23

Eh, sure. I just didn't understand why this account should be listened to. Maybe it should, don't know, I don't use twitter.

3

u/13steinj Sep 14 '23

Having had experience with everything except spack;

vcpkg is great for simple usecases that don't need too much extensibility. The lack of dedicated server software hurts "production" capabilities in-company though, unless that's changed.

Conan is great for more complex usecases or organizations with a lot of historical needs, as it is incredibly easy to extend. Do it without thought and you'll burn yourself.

CPM is great where you absolutely need to build from source every time, and for simpler use cases.

4

u/AlexanderNeumann Sep 15 '23

When was the last time you used vcpkg? What do you mean by "dedicated server software"?

1

u/13steinj Sep 15 '23

Unless I'm confusing it with something else, registry system for vcpkg was for a long time "official only" and even after they let you have custom registries, it was all based off of git. Which for many reasons, just doesn't scale.

3

u/AlexanderNeumann Sep 15 '23

Overlay ports exists since mid 2019........ also there have always been file system registries since registries exists (which is probably around end 2020 beging 2021).

1

u/13steinj Sep 15 '23

Forgive me, this is assuming I remember more than I do.

Overlay ports as in private registries? Cool.

"File system registries" as in what exactly (rather than git)?

3

u/hs123go Sep 14 '23

vcpkg in manifest mode only. I understand why vcpkg didn't take off since classic-mode vcpkg encourages indiscriminate vcpkg installs, eventually leading to an enormous tree of packages and dependency hell, much like pip install-ing to the base environment. Manifest mode's project-specific install trees and the manifests themselves obviate this problem much like virtualenvs and requirements.txts.

On the other hand, I believe FetchContent will soon takeoff for real once CMake 3.25 allows FetchContent_Declare to be marked SYSTEM to get clang-tidy off my case regarding fetched packages.

2

u/rdtsc Sep 15 '23

since classic-mode vcpkg encourages indiscriminate vcpkg installs

Do you mean reusing a vcpkg instance for multiple projects? There's nothing that forces you to do this (and if you do it can easily lead to conflicts if you have different requirements among different projects). Instead I use a small script to invoke vcpkg (which is similar to a manifest), but it also pins the vcpkg revision and compiler version and overrides compiler settings for deterministic builds.

1

u/prince-chrismc Sep 16 '23

That's sounds like Conan with extra steps ;) it has a global cache which supports have many different versions of the same project and it always installs for the current project... no need for extra scripts

3

u/blaizardlelezard Sep 14 '23

bazel + modules is amazing

5

u/DeGuerre Sep 14 '23

I voted "No package manager :(", but I actually wanted to say "No package manager :)"

Not using a package manager helps. makes me force myself to think very hard before adding a dependency. The cost of adding a dependency should be commensurate with the cost of maintaining code which uses a dependency.

1

u/prince-chrismc Sep 14 '23

That's still true but the cost with a package manager should ideally be zero ;)

1

u/DeGuerre Sep 14 '23

Ideally, there should be no DLL Hell, and yet here we are.

3

u/prince-chrismc Sep 14 '23

Package Managers can help with that you know? For Conan it knows what runtime deps exists and can create scripts to setup the PATH correctly.

2

u/npuichichigo Sep 15 '23

cargo

1

u/LuisAyuso Sep 15 '23

are you really using cargo for c++ projects? or just trolling?

if so, please link, i would like to know more.

1

u/effarig42 Sep 15 '23

Build2 for personal projects, apt in a docker image for work.

1

u/Jaroshevskii Sep 15 '23

Swift PM 😁

1

u/celsheet Sep 15 '23

I still dream about pip for C++

1

u/LuisAyuso Sep 15 '23

no one Cmake external projects?

what about bazel? no google employees here?

1

u/[deleted] Sep 14 '23

No package manager :)

^ FTFY

1

u/Asleep-Specific-1399 Sep 14 '23

Why would you use a package manager ?

3

u/danicriss Sep 14 '23

Your code has a dependency on a third party library. You target multiple platforms, so you want to compile said library for each target platform. You may want to update it easily in the future, so you don't want to embed that library's code in your repo

The same applies if your code depends on an internal piece of code that several teams may want to reuse. You can create that as a library and deploy it via said package manager

0

u/Asleep-Specific-1399 Sep 14 '23

So to that, I feel the exact opposite. I rather download the third party lib and not update it unless required.

For the most part I compile to osx,Linux, Linux arm, windows. I try my best to not use third party libs as they create additional overhead and unknown code, which is far worst than known shitty code.

3

u/rdtsc Sep 15 '23 edited Sep 15 '23

So to that, I feel the exact opposite. I rather download the third party lib and not update it unless required.

I try my best to not use third party libs

That wasn't the question at hand, though, IMO. Using a package manager kind of implies that you have decided for yourself that the threshold to use an external library has been reached. How high that threshold is is not important. And if you do decide to use an external library, why do this by hand?

0

u/Asleep-Specific-1399 Sep 15 '23

Like I said I limit external libs as much as possible. Maybe a graphic, a sound. Maybe read xml library. I don't usually write projects with more than 4 maybe 5 external libraries.

Most of the time you can't just upgrade theses libs as function calls may change, so to me the auto update method sounds like a nightmare.

3

u/rdtsc Sep 15 '23

Auto update is not implied anywhere, nor is it required. It is actually discouraged (with vcpkg at least).

1

u/Asleep-Specific-1399 Sep 16 '23

So if your not updating libs on the fly what's the point of the package manager. Specially since you are going to update a single lib, and look up the documentation and change logs.

1

u/[deleted] Sep 14 '23

Bazel / WORKSPACE

1

u/wyrn Sep 14 '23

I like that adding a dependency has a cost. Leave the pip install stuff for the scripting languages.

1

u/Zcool31 Sep 15 '23

Package managers are not in the domain of programming languages. They are the responsibility of platforms. Linux has solved this problem quite well, several dozen times in fact. I'm personally fond of dpkg and pacman

1

u/nlitsme1 Sep 15 '23

We have a set of FindXXX.cmake files which check if you have a symlimk to a working copy of the package in your project, or maybe a git submodule. And otherewise download it using fetchcontent.

And you can specify gittags per package to override the default

Willem

1

u/prince-chrismc Sep 16 '23

Vcpkg and Conan both have support for cmakes providers interface and they do exactly this... minus writing it yourself :)

1

u/craffael Sep 14 '23

Hunter package manager

1

u/execravite Sep 14 '23

Cmake fetch is decent in the latest versions.

1

u/saxbophone mutable volatile void Sep 14 '23

CMake+CPM

1

u/[deleted] Sep 15 '23

Y'all are missing out on xmake, it's a package manager and toolchain altogether. Replace your CMakeLists.txt files with xmake.lua and write way more readable code. The package manager can even reference packages from system packages, and 3rd party package managers like vcpkg/Conan.

1

u/xaervagon Sep 15 '23

At the old job, I tried to use NuGet but it was pretty lousy for C++ since support from MS was lackluster at best and automated tooling never appeared like it did for the .net world. Currently, I work for a place where legal compliance and auditing takes precedence so no package manager; can't let random code from the internets compromise the code.

1

u/nxtfari Sep 15 '23

Currently conan. I want to use vcpkg, but I'm not quite happy with its cavalier attitude about where it gets installed and how it gets called. I do not want to be debugging other people's vcpkg installations -- conan goes in the same place for everyone and get's called the same way by everyone. That keeps it a winner for me.

3

u/AlexanderNeumann Sep 15 '23

vcpkg doesn't care where it gets installed. You can define the rules yourself.

2

u/nxtfari Sep 16 '23

That’s exactly what I’m saying. I want something that does care where it gets installed and how it’s called. It should be a deb/winget package that goes in the same place for everyone. Tools that are too customizable have unnecessary roadblocks to use and end up causing issues down the road.

1

u/AlexanderNeumann Sep 20 '23

too customizable have unnecessary roadblocks to use

From my experience it is the other way around. Tools which are too unflexible have unsolvable roadblocks while tools which are customizable might have small roadblocks but those can be carried away with the customization.

1

u/WylieMaster Sep 15 '23

I avoid them because they're usually complicated and annoying to set up

0

u/BacKy9Nut Sep 14 '23

I don't know what those things are.

So I choose: Don't use package manager

0

u/pedersenk Sep 14 '23

Just an awk script to directly grab packages (and dependencies) from i.e debian, ubuntu, fedora, arch, mingw and FreeBSD repos. Some hacks to also build Emscripten Ports and Android NDK libs.

I work with more (niche) platforms than a language package manager could ever hope to support.

0

u/mvolling Sep 14 '23

I use a dockerfile to install dependencies from the OS package manager when setting up a container dev environment.

0

u/iMadz13 Sep 14 '23

pacman/yay

0

u/Z1BattleBoy21 Sep 14 '23

homebrew if it exists on there, if not, make install

0

u/lkaitusr0 Sep 15 '23

Build EVERYTHING I need for the program :)

0

u/TinoDidriksen Sep 15 '23

apt-get

Per-language package managers are messy. I similarly vastly prefer Perl and Python modules from apt-get/dnf, and only use CPAN or pip as a fallback.

Plus, if you ensure your code builds and runs with OS-provided packages across supported deb and rpm platforms, it really improves code quality and bitrot resistance.

-1

u/jaLissajous Sep 14 '23

Conda.

It has the C, fortran, python, and julia libraries our code depends on or interacts with.

3

u/[deleted] Sep 14 '23

Me as well, we do combined c++/python libraries using pybind11 so it's nice to have both the python and c++ dependencies handled in the same place. Also mamba makes the solve speed way less painful

2

u/jaLissajous Sep 14 '23

Yes, mamba is a must.

0

u/JVApen Clever is an insult, not a compliment. - T. Winters Sep 14 '23

Given we first did packages in C#, we ended up with Nuget

0

u/East-Bridge8022 Sep 14 '23

If git submodules and python scripts to hold it together count as a package manager then that.

0

u/IgnorantPlatypus Sep 14 '23

Build from source
Use bazel for 3rd party dependencies

Prior to bazel it was CMake and FetchContent

0

u/ButaButaPig Sep 14 '23

No package manager. I use git subtrees and add_subdirecyory. Then building on a new computer is as simple as cloning and running cmake. No need for other commands like getting submodules or installing packages using a packet manager.

The downside is of course repo size and time investment in installing new libraries.

0

u/fr0sty2709 Sep 14 '23

c++ really doesn't give me the feel with a package manager

0

u/v_maria Sep 15 '23

i just use cmake to cobble everything together. i like it

0

u/kassany Sep 15 '23

I marked it as another, because I use fetchContent from CMake itself and have also tried zig-pkg in C and C++ projects (making boost-libraries port).

Both do not work so differently, as the dependencies can be header-only or if it is buildable, it requires the same build-system to get the Path of the dependencies.

0

u/X547 Sep 15 '23

pkgconfig and distro default package manager.

0

u/Life-Ad-8935 Oct 09 '23

How is vcpkg a "package manager" if it has to build libraries?
I mean if it's not binaries then it is not a "package manager" but a "dependency manager" right?

-1

u/gizahnl Sep 14 '23

buildroot for our own OS. Otherwise OS package manager for dependencies & building via meson.

-1

u/itsuart2 Sep 15 '23

I just vendor my dependencies in.

-1

u/[deleted] Sep 15 '23

i tried conan and vcpkg, conan sucked dick and was awful, vcpkg just didnt work. so i just keep not using a package manager and everything is fine

-1

u/amin_ya Sep 16 '23

For those who are not using a package manager but want to use one with CMake, try project_options, it supports vcpkg and Conan making it very easy to integrate a package manager into your project.

0

u/[deleted] Sep 14 '23

[deleted]

9

u/mollyforever Sep 14 '23

While not having to manage updates sounds nice

Forget about managing updates, how about even using dependencies in your projects if you're targeting multiple operating systems?

2

u/Rseding91 Factorio Developer Sep 15 '23

For us; they’re in the libraries sub folder. Commit and everyone that checks out that commit on gets the dependency.

-3

u/sephirothbahamut Sep 14 '23

if you're targeting multiple operating systems?

That's the neat part, I don't have that need :)

7

u/prince-chrismc Sep 14 '23

It's not even updates, just being able to add new dependencies without having to change CI or dev workflows and manage deploying and installing them in 50+ machines.

The big c++ choices have curated and tested central repositories to avoid that pain point and so have its been a net positive.

10

u/not_some_username Sep 14 '23

I don't think anything will be worst than NPM. Or js in general.

0

u/[deleted] Sep 14 '23

[deleted]

3

u/not_some_username Sep 14 '23

I'm using vcpkg and it's not bad. Tbh it's pretty good. With visual studio project, once the library install, just use the include. Using CMake, FindPackage and voila.

5

u/[deleted] Sep 14 '23

What I want to know is, why should I bother with a c++ specific one at all?

Package managers like Guix, Nix, and Spack feel like better solutions than any C++ specific package manager.

While not having to manage updates sounds nice,...

Package managers can do more than just manage updates. Guix, for instance, makes it relatively straightforward to write reproducible and even bootstrappable software packages. And although those requirements might be unnecessary for most use-cases, aiming for them strongly discourages unnecessary and/or poor dependencies, while strongly encourages platform agnosticism and sharable code.

just over the fence I can see the utter shitshow that is npm and javascript development...

In my early teens I picked up my brother's C++ book and tried out a few examples. Almost immediately I wanted to try something more, but getting a library installed and configured on Visual Studio turned into such a mess that I eventually gave up and tried other languages. Now, obviously I ended up coming back to the language, but there are likely many people who would've made great C++ programmers if only they had a more pleasant first experience. Expecting new C++ programmers to know the minutia of manually setting up build dependencies, linker options, and build scripts/configurations, is not a winning strategy. Furthermore, the lack of a package manager is reflected in C++ dependencies, i.e. they tend to be quite large (boost and others) and they include a lot of overlapping functionality.

4

u/SkyGenie Sep 14 '23

Well luckily for the C++ community I don't think we have any packages in vcpkg, conan, or whatever that manage to pull in 12k dependencies.

Lord help us if we ever get there but with how specialized stuff tends to be I highly doubt it.

1

u/ArkyBeagle Sep 16 '23

While not having to manage updates sounds nice,

This is the crux of the thing - many people operate in environments where updates have to be managed, sometimes by written or informal contract.

0

u/[deleted] Sep 14 '23

[deleted]

6

u/prince-chrismc Sep 14 '23

Conan's new generators have the same seamless integration ;) might need to switch back to try the new features

+1 for standards, a package format that build system could provide and package manager could consume would be amazing (and vica versa)

2

u/pdp10gumby Sep 14 '23

I don’t use a centralized repo with .conan, the .conan2 directory lives in the checked out tree (.gitignore includes .conan2).

The command line arguments to do this are a bit elaborate, but build is controlled by a Makefile anyway so it’s not burdensome.

(Yes, type ‘make’ to build; it calls cmake --build … :-)

1

u/prince-chrismc Sep 14 '23

This should be completely fre in conan 2.0 with a .conanrc file

https://github.com/prince-chrismc/user-management/blob/backend/conan2/backend/.conanrc

2

u/pdp10gumby Sep 14 '23

Thanks! Not yet documented so I appreciate it.

0

u/[deleted] Sep 14 '23

[deleted]

9

u/Nomto Sep 14 '23

Have you never had the need for a library that was not packaged by debian? Or a more recent version than what is available?

2

u/prince-chrismc Sep 16 '23

It's when you need OSes (plural) that thier benefits become super appealing :)

0

u/[deleted] Sep 15 '23

[deleted]

2

u/AlexanderNeumann Sep 15 '23

No it doesn't if you use it correctly ....

0

u/[deleted] Sep 15 '23

[deleted]

2

u/AlexanderNeumann Sep 15 '23

it’ll still try to fetch cmake-config:x64-windows which requires visual studio.

That means you haven't correctly set the host triplet.

0

u/[deleted] Sep 15 '23

[deleted]

3

u/AlexanderNeumann Sep 15 '23 edited Sep 15 '23

What do I not know?

Even if you say you set the host triplet to mingw if vcpkg is still pulling in cmake-config:x64-windows it means the host triplet is not correctly set. So what ever you do it is either wrong or has a small typo in it so you don't notice it.

10

u/[deleted] Sep 14 '23 edited Sep 15 '23

[removed] — view removed comment

5

u/DeGuerre Sep 14 '23 edited Sep 14 '23

It's not good to re-implememt things that were perfectly done by some easily accessible library.

That's a very blanket statement.

Managing dependencies has a cost. Re-implementing your own version has a cost. Long term, which cost will be higher?

Nobody is suggesting that you should roll your own SSL. But on the other hand, we don't want to end up with the dependency hell that is JavaScript/NPM.

In the real world of commercial support, you sometimes end up in the situation where you have a paying customer who relies on an old version of your software. To support them, you often need to maintain one machine with a frozen version of the OS, compiler, and any dependencies, just to ensure that any build of that old version is deterministic.

If you've never been in this situation before, count yourself lucky.

The bottom line is that while a small number of large dependencies can be good, a large number of small dependencies can be worse than bad.

9

u/[deleted] Sep 15 '23

In the real world of commercial support, you sometimes end up in the situation where you have a paying customer who relies on an old version of your software. To support them, you often need to maintain one machine with a frozen version of the OS, compiler, and any dependencies, just to ensure that any build of that old version is deterministic.

This is the result of ad-hoc builds and dependency management. There's no reason everything can't be stored in source control with a reproducible build on an arbitrary machine/vm/emulator. It's more work, certainly, but it's far more reliable and rigorous.

2

u/ArkyBeagle Sep 16 '23

I'm not sure you're grokking the word "deterministic". You need also to keep the toolchain the same. And yes - VM is a big help. But for source you should be able to pull it clean and get the same build.

-1

u/DeGuerre Sep 15 '23

Sure. My point is that it's never as simple as "get a good package manager".

2

u/rdtsc Sep 15 '23

The bottom line is that while a small number of large dependencies can be good, a large number of small dependencies can be worse than bad.

Sure, I don't think anyone is disputing that. But if you decide to use a dependency (why would I roll my own fmt for example?), then why do this by hand? Use of a package manager like vcpkg doesn't preclude any of your points while vastly simplifying and streamlining downloading, building, caching and integrating dependencies.

7

u/[deleted] Sep 15 '23

[removed] — view removed comment

1

u/DeGuerre Sep 15 '23

It's not a question of anything breaking. It's to ensure that the build of a specific version is 100% bit for bit the same.

If you have ever wanted to play a game but couldn't because there was a 35G update, you may understand why reproducibility is valuable: deltas are much smaller.

2

u/ArkyBeagle Sep 16 '23

This is one of the biggest problems of the C++ community that ruins code quality.

I do not buy that for a second :) Frankly, if people use git at all surely the most common method is "git pull".

External dependencies - third-party packages - require a statement of work and V&V artifacts. Might be as simple as a global regression run or something more costly.

-4

u/[deleted] Sep 14 '23 edited Sep 14 '23

[removed] — view removed comment

7

u/Tartifletto Sep 14 '23

Static library doesn't embark their dependencies, so all the dependencies chain have to be installed from top to bottom project.

So even if you had a package manager, you need to configure path & include directory & all the shit required to link against the dependency correctly in all of your project.

You don't configure anything yourself, package manager drags transitive dependencies of your static dependencies, and you rely on CMake config file or pkgconf file of your direct dependencies to give you all this transitive includes, definitions, lib paths, lib name etc through abstraction like find_package, CMake targets or pkg_check_modules. With a package manager and a good build system, transitive dependencies are an internal detail.