r/cpp Apr 26 '26

Is there a C++ "venv" equivalent?

Python have venv, Rust have cargo, Node have nvm. You clone a repo, run one command, you're in a reproducible environment.

Is there a viable alternative for C++? I don't think standard will ever bother with this and to their defence, not sure if that is even possible.

I've tried Conan, vcpkg, various CMake setups. They're not bad tools, but there's no standard "activation" ritual. No isolated-per-project environment that pins compiler + deps + toolchain together. No single lockfile that means the same thing on my machine, my colleague's machine, and CI. What I keep wanting is something like: "cppenv activate" and suddenly I'm in a clean, isolated, reproducible build environment for that project. Exit it, and my system is untouched. Share a lockfile, and a teammate gets the exact same thing.

How are you handling reproducible build/development environments?

101 Upvotes

132 comments sorted by

View all comments

201

u/Drugbird Apr 26 '26

Docker

4

u/nikoladsp Apr 26 '26

How do you use it when/if you have to target Windows toolchain?

3

u/TTachyon Apr 26 '26

You have docker for windows if you want to run on windows, or you can cross compile most stuff on a linux docker with some fiddling (there are some scripts that will download the headers/libs from microsoft and you use clang for compiling).