32

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.

chmike
  • 20,922
  • 21
  • 83
  • 106
  • "Using a chroot with all the required libraries and dependencies could do the job. Does this exist ?" - well yes but you'll have to set it up yourself, and then you obviously can't read / write user files from out of the chroot. But you could probably equally place the dependencies in the same directory and / or manipulate LD_LIBRARY_PATH in a start-up script that loads your main app. But do you really need to use more recent libraries? It's often more trouble than it's worth to do ad-hoc updates like this. – Rup Feb 04 '13 at 11:30
  • Indeed I don't really need the security provided by chroot. But looking at the ldd output of my programs in the SCL6 context, I see library dependencies like /lib/ld-linux.so.2 which could be different between Debian and SCL6. I also see a library linux-gate.so.1 which doesn't have a particular path. So I'm not even sure the program would run in a chroot environment since I don't know where to put this library. – chmike Feb 05 '13 at 09:03
  • You don't. linux-gate is an interface to the kernel - it's a virtual library and doesn't exist on disk. ld-linux is the shared library loader (I think) and pretty standard too. Any of these libraries that interface directly with the kernel (libc I think too) may be different between the Linux distributions because the kernels will be different. You should just be able to use the libraries that exist in-place. – Rup Feb 05 '13 at 09:55
  • Do you want to create an SCL6-like environment on Ubuntu for development, or an Ubuntu-like environment on SCL6 for deployment? I recommend the latter. It entails just shipping a few libraries together with your program. – n. m. could be an AI Jan 22 '21 at 07:01

5 Answers5

7

You can use tools below:

soleil
  • 71
  • 1
  • 3
6

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

hdante
  • 7,685
  • 3
  • 31
  • 36
1

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.

Qortex
  • 7,087
  • 3
  • 42
  • 59
  • This looks very interesting when the dependencies don't change much. In my case I'm on a debian computer and need to develop code with dependencies with SL5 OS. I also want to be able to use QtCreator for the development. – chmike Mar 13 '13 at 10:11
1

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.

SeF
  • 3,864
  • 2
  • 28
  • 41
0

I agree with SeF using dependencies. For me, the IDE helped to set different development environment.

Regarding the IDE for different OS:

Cloud Cho
  • 1,594
  • 19
  • 22