How to install older version of gcc

Hello, I just wanted to ask if anyone knows how to install older gcc(g++) on fedora 25. I have version 6.3.1 installed, but I have a lot of issues with a rather large project, which I know runs on gcc(g++) 4.8.5. I somehow cannot find the answer.

There's compat-gcc-34 specifically 3.4.6

[a@jupiter ~]$ dnf search compat-gcc
Last metadata expiration check: 0:31:51 ago on Wed Apr 12 16:21:08 2017 BST.
============================================================= N/S Matched: compat-gcc =============================================================
compat-gcc-34.x86_64 : Compatibility GNU Compiler Collection
compat-gcc-34-c++.x86_64 : C++ support for compatibility compiler
compat-gcc-34-g77.x86_64 : Fortran 77 support for compatibility compiler

by default 6.3 on F25, 7.0.1 in F26

You might be better off running CentOS on a machine for that project which had gcc 4.8 default. Or build the GCC you need. unless 3.4 is sufficient then its there good to go.

You could also try using a copr if gcc 4.9 is sufficiant.

https://copr.fedorainfracloud.org/coprs/davidva/gcc49/

the closest you will come will be gcc-5.1.1 on fedora 25

you could try and download the gcc rpm yourself
http://rpmfind.net/linux/rpm2html/search.php?query=gcc&submit=Search+...&system=&arch=

Thanks for the tips guys, will try it out. It seems like there are just some parts that don't agree with the new version so I might try to rewrite it in a way to be compatible with both. Or I'll go with Cent OS.

Keep in mind that compiling with different versions of GCC can cause runtime issues with your program. It may be in your best interest to sort out the GCC 6.3 issues in your code. GCC is only going to move forward in versions, this isn't really a situation that's going to get any better for the program.

1 Like

What are some of the issues? Maybe we can help you through them?

4.8.5 is old and crusty by now (wouldn't recommend anything older than 4.9 nowadays). As others have said, you're probably going down the harder road trying to use the older gcc.

1 Like

I have errors like this:

 /usr/include/c++/6.3.1/bits/algorithmfwd.h:362:41: error: macro "max" passed 3 arguments, but takes just 2
 max(const _Tp&, const _Tp&, _Compare);
                                     ^

From what I found. this error is fixed by renaming the min/max declaration (it is forbidden in higher g++ versions).

After this it compiles with lots of warnings.
Warnings like this:

<code>
/home/.................../MFCport/include/AfxDiagPort.h:48:27: note: in expansion of macro ‘ASSERT’
 #define ASSERT_VALID(x)   ASSERT(x)  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                           ^~~~~~
../src/array_u.cpp:153:2: note: in expansion of macro ‘ASSERT_VALID’
  ASSERT_VALID(this);
  ^~~~~~~~~~~~
../src/array_u.cpp: In member function ‘void CUIntArray::FreeExtra()’:
/home/.................../MFCport/include/AfxDiagPort.h:33:22: warning: nonnull argument ‘this’ compared to NULL [-Wnonnull-compare]
   #define ASSERT(x) {if(!(x)) { std::cout << "Dbg: assertation failed! (" << __FILE__ << ", line: "<< __LINE__ << ")" << std::endl; raise(SIGTRAP)/*asm("int $3")*/;}
}
                      ^
</code>

These seem to be a result of using CString ...

Since it involves macros, that looks much like a redefinition. First thing I would do is make sure the macro max isn't being redefined in another header you're including and subsequently adjust the order you're including headers in.

Or perhaps call #unset max before including the problematic header, depending on how it's getting pulled in.

Is this a port from Windows?

Hello, sorry for the late reply. Yes it is a port from windows. Thankfully I am progressing fast, I just need to change some smaller stuff. Thanks for all the help. I was afraid the compatibility would be a bigger problem, but it is showed up to be fine. It was first done in Windows in Visual Studio, then ported (with lots of temporary and non-standard patches) onto an eclipse project in a CentOS virtual machine. Now I am rewriting it to be compatible with the g++ version in Fedora 25 and using only make. With help from here and lots of googling, I have moved a significant bit forward. I am just glad I did not lea it in a virtual OS.

No worries. Glad to hear you were able to make progress!