Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent of python's virtualenv for C/C++ programs?

Tags:

c++

c

virtualenv

I have to develop C++ programs that have to run on Scientific Linux 5 or 6. I would like to develop with QtCreator on Ubuntu which has much more recent libraries than the one found on SCL6.

Is there an equivalent of Python's virtualenv for C/C++ programs ?

Using a chroot with all the required libraries and dependencies could do the job. Does this exist ? See http://rcrowley.org/articles/dependencies.html on the use of chroot.

like image 252
chmike Avatar asked Feb 04 '13 11:02

chmike


4 Answers

Use debootstrap to create the chroot environment (or even install ubuntu on a separate partition). Mount your home dir with mount -o bind. Use schroot convenient chroot setup.

http://manpages.ubuntu.com/manpages/precise/en/man8/debootstrap.8.html

http://manpages.ubuntu.com/manpages/precise/en/man8/mount.8.html

http://manpages.ubuntu.com/manpages/precise/en/man1/schroot.1.html

like image 54
hdante Avatar answered Oct 22 '22 20:10

hdante


You can use tools below:

  • conan virtual environment (https://blog.conan.io/2016/08/04/Conan-virtual-environments-Manage-your-C-and-C++-tools.html)
  • conda virtual environment (https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
  • docker container
like image 22
soleil Avatar answered Oct 22 '22 20:10

soleil


Not sure it is lightweight enough for what you need (I'm not very familiar with virtualenv) but you can try the CDE Project which is a very nice way of creating a virtual sandbox with all kinds of dependencies.

like image 1
Qortex Avatar answered Oct 22 '22 20:10

Qortex


You can establish the dependencies and the compiler for a given project using a build system like bazel (https://bazel.build/) or please (https://please.build/).

It will never be the same exact as a virtualenv, due to the different nature of the language, and since it will still be using the system compiler. In case you want to have your project completely isolated, you can ship the project on a docker container.

like image 1
SeF Avatar answered Oct 22 '22 20:10

SeF