Downgrading gcc

Circuits

New Member
Is downgrading my gcc from 8.1 all the way to 4.7 going to be possible? Would it be as easy as:

apt-get remove gcc-8.1.0
apt-get install gcc-4.7

Or am I going to run into unforeseen complications if I try to do that?
 


ryanvade

Moderator
Staff member
Gold Supporter
You will most likely run into trouble doing that. It would be easier to build gcc-4.7 manually.
EDIT* I don't think gcc-4.7 conflicts with gcc-8.1.0 so why not install both side by side?
 

Circuits

New Member
You will most likely run into trouble doing that. It would be easier to build gcc-4.7 manually.
EDIT* I don't think gcc-4.7 conflicts with gcc-8.1.0 so why not install both side by side?
To be honest, I am not the most competent Unix user in the box. If I tried installing it along with 8.1 how might I direct a program like Qt to use the version 4.7 rather than the 8.1?
 

JasKinasis

Well-Known Member
If you don't mind me asking - which version of QT is being used to create the application you are trying to build?
And is there any particular reason why you need gcc 4.7? Is the application quite old? or is there another reason?

As Ryan has stated - You can install multiple versions of gcc alongside each other.

As for compiling a QT application with a different version of gcc - you may be able to change your default compiler to g++-4.7.

I'm on my lunch-break at work, so not near a Linux PC ATM, but if memory serves - I think the easiest way would be to redirect g++ to g++-4.7.
Normally g++ is a symbolic link to the latest version of g++. So if you have g++-8.0 installed, then g++ will be a symbolic link to the g++-8.0 executable.

You can combine the file and which commands to find out what type of file your default g++ is:
Code:
file $(which g++)
I think that will output something like:
Code:
/path/to/g++: symbolic link to /path/to/g++-8.0
NOTE: /path/to/g++ will NOT be in the output, it will be something more like /usr/bin/g++

IF your default g++ is a symbolic link AND IF you have g++ 4.7 installed - then as root, you could try removing the symbolic link to g++-8.0 and add a link to the g++-4.7 executable instead.
Something like this:
Code:
sudo rm /path/to/g++
sudo ln -sT /path/to/g++-4.7 g++
Again, replace /path/to/ with whatever the appropriate path is!

And those commands should make g++-4.7 your default version of g++.

And of course you can always restore the sym-link to g++-8.0 after you have finished working on the QT application.

But again - This potential solution would ONLY work IF you have g++-4.7 installed AND IF g++ is a sym-link to a particular version of g++.
 

ryanvade

Moderator
Staff member
Gold Supporter
This sounds like Qt 4 which only worked with gcc 4.7.

Anyway, after installing the different versions of gcc you can switch the symlinks as @JasKinasis mentions or use update-alternatives to do it for your.

Code:
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
 

Circuits

New Member
If you don't mind me asking - which version of QT is being used to create the application you are trying to build?
And is there any particular reason why you need gcc 4.7? Is the application quite old? or is there another reason?
The version of Qt that I know works for sure is 4.7.

As for compiling a QT application with a different version of gcc - you may be able to change your default compiler to g++-4.7.

...I think the easiest way would be to redirect g++ to g++-4.7.
Normally g++ is a symbolic link to the latest version of g++. So if you have g++-8.0 installed, then g++ will be a symbolic link to the g++-8.0 executable.
So rather than force the application like Qt to compile with a certain compiler. I would just force my machine to compile with one or the other?

You can combine the file and which commands to find out what type of file your default g++ is:
Code:
file $(which g++)
I think that will output something like:
Code:
/path/to/g++: symbolic link to /path/to/g++-8.0
NOTE: /path/to/g++ will NOT be in the output, it will be something more like /usr/bin/g++
That seems right here is what I got:
Code:
[email protected]:~$ file $(which g++)
/usr/bin/g++: symbolic link to /etc/alternatives/g++
IF your default g++ is a symbolic link AND IF you have g++ 4.7 installed - then as root, you could try removing the symbolic link to g++-8.0 and add a link to the g++-4.7 executable instead.
Something like this:
Code:
sudo rm /path/to/g++
sudo ln -sT /path/to/g++-4.7 g++
Again, replace /path/to/ with whatever the appropriate path is!

And those commands should make g++-4.7 your default version of g++.

And of course you can always restore the sym-link to g++-8.0 after you have finished working on the QT application.

But again - This potential solution would ONLY work IF you have g++-4.7 installed AND IF g++ is a sym-link to a particular version of g++.
Alright, I will browse the ether and see if I can find a proper version of g++4.7 source. Where should I extract the tarbal?
 

Circuits

New Member
A bit of an update:

I found two guides: https://gcc.gnu.org/faq.html#multiple and http://www.tellurian.com.au/whitepapers/multiplegcc.php

Interestingly, both guides refer to gcc being located in usr/local/gcc; however, on my machine there is no gcc director within local. I did find a directory named gcc located in usr/lib. Currently it contains a directory called: x86_64-linux-gnu, have I found the correct directory? Within it are 9 more directories: 4.8, 4.8.5, 5, 5.5.0, 6, 6.4.0, 7, 7.3.0, 8. Are these all different gcc versions I have?? I certainly do not remember downloading/installing them.

Edit:
I noticed something about the x86_64-linux-gnu directory. Out of the 9 files located there some have a black arrow on the icon and others do not. I believe this means that they are symbolic links right?

Also, which of these links is what I am looking for: https://ftp.gnu.org/gnu/gcc/gcc-4.7.4/?
 
Last edited:

Members online


Latest posts

Top