|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Setting up a C++ (and python) environment on Linux with micromamba (and VsCode)" |
| 4 | +--- |
| 5 | + |
| 6 | +I've been shilling micromamba a fair bit on both C++ and python servers that I'm a part of. Kind of become |
| 7 | +"that" guy. I've been promising people for a while I'll give a brief intro on it, and especially, helping |
| 8 | +people get started with a C++ development environment. Because it's definitely not trivial. |
| 9 | + |
| 10 | +This is that intro. The earlier sections cover setting up a micromamba environment with everything you need, |
| 11 | +and is relevant to both languages. Then I'll talk about building C++ code and setting up VsCode - this part is |
| 12 | +just for C++ because in Python this stuff will just work (of course). |
| 13 | + |
| 14 | +The only prerequisite is a sane version of Linux. WSL is also fine (where I'm testing this in fact). MacOS |
| 15 | +is also fine, but the command to (WSL is fine - where this is |
| 16 | +being tested in fact) and basic command line |
| 17 | +familiarity. if you care about the VsCode setup, then have it installed and have |
| 18 | +basic familiarity (or be ready to Google) as I won't cover that. |
| 19 | + |
| 20 | +## Install Micromamba |
| 21 | +Throughout this post I'm going to work entirely in one directory so that at the end, if you're not pleased, you |
| 22 | +can easily delete everything. |
| 23 | + |
| 24 | +```bash |
| 25 | +cd # Switch to home directory |
| 26 | +mkdir asp && cd asp |
| 27 | +``` |
| 28 | + |
| 29 | +{% highlight bash %} |
| 30 | +cd # Switch to home directory |
| 31 | +mkdir asp && cd asp |
| 32 | +{% endhighlight %} |
| 33 | + |
| 34 | +The command given is for Linux x86_64.... |
| 35 | + |
| 36 | +Next, add the following lines to your .bashrc (if you use zsh - then add it to your .zshrc). |
| 37 | + |
| 38 | +{% highlight bash linenos %} |
| 39 | +export MAMBA_ROOT_PREFIX=~/asp/micromamba # optional, defaults to ~/micromamba |
| 40 | +eval "$(~/asp/bin/micromamba shell hook -s posix)" |
| 41 | +# micromamba activate default_env |
| 42 | +{% endhighlight %} |
| 43 | + |
| 44 | +Notice the last line is commented - we'll come back to that. Go ahead and source your bashrc. |
| 45 | + |
| 46 | +## Install an environment |
| 47 | + |
| 48 | +Next, run |
| 49 | + |
| 50 | +{% highlight bash linenos %} |
| 51 | +micromamba create -f default_env.yaml |
| 52 | +{% endhighlight %} |
| 53 | + |
| 54 | +You'll be shown a list of everything being installed and prompted - hit y. Installing should just take a few |
| 55 | +seconds. |
0 commit comments