openSUSE 13.2 multiple gcc version

Hi, first time poster here… hope this is the right place!

Is it possible to install multiple versions of gcc (say 4.6, 4.8 and 4.9) at the same time? Using zypper, it seems to want to replace one with the other (and I can’t even find 4.6…).

Thanks!

It is possible but you have to manage everything about it. The kernel and other program rely on a given version of gcc libraries and if you change it it can cause you major problems so…

Maybe if you need different versions for development you can do things in a VM with a kernel and other program that like the version in question. IMO it is very complicated and I’d need a really good reason to even try it.

Well that’s a bummer… guess I’ll have to stick with Ubuntu or try a different flavour of Linux after all. :frowning: And I just spent 5 days setting SUSE with everything I need…

Unfortunately, VM is gonna be complicated as I’m using CUDA, and I got some pre-complied CUDA libraries that will only compile with gcc46. I could just copy the binaries for gcc46 and g++46 and whatever libraries I need (then link everything manually), but I do this kind of stuff very often and this will be a real drag having to move binaries of compilers around (assuming they will even work in SUSE).
Also is openmp support in gcc missing? Can’t seem to locate libgomp or find a way to install it.

Thanks for the reply.

On Fri, 01 May 2015 17:56:01 +0000, qiUip wrote:

> Hi, first time poster here… hope this is the right place!
>
> Is it possible to install multiple versions of gcc (say 4.6, 4.8 and
> 4.9) at the same time? Using zypper, it seems to want to replace one
> with the other (and I can’t even find 4.6…).
>
> Thanks!

Well, yes, 4.8 and 4.9 have separate packages, so yes, those can be
installed side-by-side, as far as I can tell.

For 4.6 you would probably need to use some other repo or roll your own,
but that wouldn’t be difficult to do with OBS.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

But the system has to run on one and the others are there just for compiling and maybe running the compile programs. It is unlike java (which you can have multiple versions) in that the C libraries are absolutely needed for the system to run. Running VM’s with properly configure system for each version is the lest likely to cause any problem or be too complicated to manage.

So the OP never said why they wanted to do this and maybe some other work around may be possible if we understood the problem they are trying to solve with multiple C++ versions.

I would indeed want the other versions only for compiling my own codes and not for OS related stuff.
My issue was that when trying to install different version via zypper I was only given an option to uninstall 48 or break 49 (so not a full install? I’m not sure how this part works…). I guess I’ll take the plunge and install it ‘broken’ to see what does and doesn’t work.

Thanks again.

On 2015-05-01 23:06, gogalthorp wrote:

> So the OP never said why they wanted to do this and maybe some other
> work around may be possible if we understood the problem they are trying
> to solve with multiple C++ versions.

He did say:

|> I’m using CUDA, and I got
|> some pre-complied CUDA libraries that will only compile with gcc46.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

On 2015-05-01 23:46, qiUip wrote:
>
> My issue was that when trying to install different version via zypper I
> was only given an option to uninstall 48 or break 49 (so not a full
> install? I’m not sure how this part works…). I guess I’ll take the
> plunge and install it ‘broken’ to see what does and doesn’t work.

No, that will not work, IIRC. I think you have to install it on another
path, which is not possible to do with a prepared rpm. I have the vague
recollection of having read about this before.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

On Fri, 01 May 2015 21:06:02 +0000, gogalthorp wrote:

> But the system has to run on one and the others are there just for
> compiling and maybe running the compile programs. It is unlike java
> (which you can have multiple versions) in that the C libraries are
> absolutely needed for the system to run. Running VM’s with properly
> configure system for each version is the lest likely to cause any
> problem or be too complicated to manage.

Using osc to do local builds also would take care of this. I use osc to
build stuff for SLES 11 SP3 - which uses a different version of GCC than
openSUSE 13.x - and that works just fine. osc actually sets up the
proper build environment based on the repos selected as build
requirements.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Thanks a lot Jim.

Had a look at OSC and it seems too much hassle and quite a learning curve when I’m trying to streamline my research… Maybe I’m just missing something, but I couldn’t seem to find out how to search for specific applications or how to easily manage installed ones - and I spent a good hour+ on it.

I’m still getting very weird behaviour with my parallel (OpenMP) codes in openSUSE (using gcc48) and overall a quite confused experience so far. I still want a simple way to install multiple versions of the same compilers, but I guess for when I truly need that I’ll just boot into Ubuntu or OSX on my laptop. Maybe when I have more time I’ll look into OSC in more detai as I would really like to be able to stop booting into different OSes and using different comps…

Thanks again! :slight_smile:

Heh, great, thanks for letting me know and saving me the headaches of fixing broken packages. :stuck_out_tongue: I guess I’ll just have to live without multiple versions of compilers for now.

Thanks!

If the programs are open source just recompile them but if binary blobs you have to get the people that made them recompile. Easier said then done

Another possibility is that what you really need is the libraries. If so then perhaps putting the appropriate lib in the same directory as the executable would work. You don’t actually need the compiler just the correct libs. Most programs will look at local directory first before going to the path to find a lib

On 2015-05-02 17:16, qiUip wrote:

> OSC in more detai as I would really like to be able to stop booting into
> different OSes and using different comps…

You can also use virtual installs.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

Been awhile since I dabbled in a little CUDA, I can’t remember for sure that there was any kernel modification, I only remember that an nVidia GPU with CUDA support was required (I think today there aren’t special CUDA GPUs, all proprietary nVidia drivers should support CUDA).

If that’s the case, I’d guess that it should be possible to build your special environment in a Linux container, and I’d probably recommend openSUSE 13.1 to be sure you have access to the older gcc libraries.

To build in a Linux container, you can do this either with LXC or Docker (the latter would be my preference today).
In a Docker container specifically, the only shared resources between your Host and each Container “Guest” would be CPU resources. Everything related to the the running Container should run in its own isolated namespace and to the guest, everything would appear as bare metal hardware.

If you don’t know anything about Docker, I wrote a small blurb in these Forums here. Any further questions can be posted in the Virtualization forum
https://forums.opensuse.org/showthread.php/500072-How-to-Docker-on-openSUSE?p=2664662#post2664662

TSU

On Sat, 02 May 2015 15:16:02 +0000, qiUip wrote:

> Thanks a lot Jim.
>
> Had a look at OSC and it seems too much hassle and quite a learning
> curve when I’m trying to streamline my research… Maybe I’m just
> missing something, but I couldn’t seem to find out how to search for
> specific applications or how to easily manage installed ones - and I
> spent a good hour+ on it.

Once you get it set up, it’s actually a lot simpler. It does have a
little bit of a learning curve, but once you get there, it is extremely
slick.

> I’m still getting very weird behaviour with my parallel (OpenMP) codes
> in openSUSE (using gcc48) and overall a quite confused experience so
> far. I still want a simple way to install multiple versions of the same
> compilers, but I guess for when I truly need that I’ll just boot into
> Ubuntu or OSX on my laptop. Maybe when I have more time I’ll look into
> OSC in more detai as I would really like to be able to stop booting into
> different OSes and using different comps…
>
> Thanks again! :slight_smile:

No problem - I understand the need. Something else you might look at as
an alternative is using Vagrant to deploy different build environments
based on the compilation need. It’s again a little more involved than
doing what you’re dong with Ubuntu or OSX, but something that I always
try to keep in mind as well is when there’s multiple sets of libraries,
compilers, and other stuff installed, managing the differences in the
environments can be pretty hairy, and if you indavertently link to the
wrong version of something, that can create all sorts of problems.
Separate environments are going to give you a clean “sandbox” to work
from where you know the dependent libraries are all you’re going to link
to - and for the version of the compiler you’re using.

OSC helps manage some of that, because the build environment is specific
to the requirements given at build time (in the spec file if an RPM
target is used, or whatever’s used for building .deb packages or other
platforms). OSC is part of the open build services at build.opensuse.org,
so that might also give you some stuff to look at that can help you with
your build stuff. The thing that OSC brings that OBS doesn’t do on its
own is local builds - builds on the build service servers tend to take a
bit longer to execute because they’re queued up with other packages being
built in the cluster.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

you can install them side by side
the OBS /devel/gcc repo has a few builds

BUT!!!
and this is a PROBLEM!!!

some things like the kernel and nvidia drivers and other kernel mods NEED!!! the default version of gcc

so having 4.8 and 4.3 and 4.1 and 3.3 installed
you need to use "alternatives " to set it

or
i use a shell script
( this is VERY!!! dependent on what YOU!!! have installed )
this below MUST BE EDITED FOR YOUR SET UP !!!

set_gcc4.3.sh


#!/bin/bash

rm /usr/bin/cpp
ln -s /usr/bin/gcc-4.3 /usr/bin/cpp
echo ln -s gcc-4.3 cpp

rm /usr/bin/cc
ln -s /usr/bin/gcc-4.3 /usr/bin/cc
echo ln -s gcc-4.3 cc

rm /usr/bin/gcc
ln -s /usr/bin/gcc-4.3 /usr/bin/gcc
echo ln -s gcc-4.3 gcc

rm /usr/bin/c++
ln -s /usr/bin/g++-4.3 /usr/bin/c++
echo ln -s g++-4.3 c++

rm /usr/bin/g++
ln -s /usr/bin/g++-4.3 /usr/bin/g++
echo ln -s g++-4.3 g++

rm /usr/bin/gcov
ln -s /usr/bin/gcov-4.3 /usr/bin/gcov
echo ln -s g++-4.3 g++

rm /usr/bin/gfortran
ln -s /usr/bin/gfortran-4.3 /usr/bin/gfortran
echo ln -s gfortran-4.3 gfortran 

you need to make one for EACH version of gcc