Snap confined development environment?

I’ve been toying with the idea using a confined snap as a fast way to set up a specific development environment (tool chain, dependencies, etc.) for particular pieces of work. E.g. for a workshop.

Snap packaging makes it easy to set up across distros and series, and confinement avoids it causing any issues on the host systems.

I had a brief try, but quickly found issues:

$ g++ hello_world.cpp
In file included from /snap/miroil-dev-env/x7/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h:482:0,
                 from /snap/miroil-dev-env/x7/usr/include/c++/5/iostream:38,
                 from hello_world.cpp:1:
/snap/miroil-dev-env/x7/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h:39:22: fatal error: features.h: No such file or directory
compilation terminated.

Before spending time investigating such problems and devising my own solutions, I wondered if anyone else has been down this road and what they might have found?

take a look at:

it ships a toolchain and all necessary/possible headers for npm to actually build modules inside the snap env. on the fly
Key are the env variables as well as managing the gcc symlink (that is usually set by update-alternatives which is omitted in stage-packages)

Thanks for that @ogra, that gave me a route past a lot of issues. (Still not quite there, but the weekend is coming up.)

I’m hoping I am missing something obvious and someone will share the right magic, but I’m having trouble with CMake’s check_cxx_symbol_exists() in a confined environment.

I’ve an example here:

Which tries to set up a build environment for a branch of Mir. However, this fails with:

CMake Error at src/common/sharedlibrary/CMakeLists.txt:27 (message):
  Could not detect dlvsym or dlsym

That, in turn seems to be because:

check_cxx_symbol_exists("dlvsym" "dlfcn.h" HAS_DLVSYM)
check_cxx_symbol_exists("dlsym" "dlfcn.h" HAS_DLSYM)

Doesn’t work, not because the symbol isn’t there, but because check_cxx_symbol_exists() isn’t working.