Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install a new version of gcc on ubuntu

I am using ubuntu 9.10 and it comes with gcc 4.4. How can I install gcc 4.5 without screwing up my gcc 4.4. environment. I just need gcc 4.5 to compile 1 application.

Thank you.

like image 575
michael Avatar asked Apr 23 '10 19:04

michael


People also ask

How to install GCC on Ubuntu 20 04?

The first step then is to install Homebrew on Ubuntu 20.04 / Debian 10 after that we can continue without any problems. The next step is to simply run the brew command to install GCC, the latest version of which is 11.1. Then the whole download and installation process will start.

How to switch between GCC versions?

To switch between gcc versions, I used the following: Show activity on this post. You need to use the equals sign instead of the colon. You'll also need to update your default gcc config. How to change the default GCC compiler in Ubuntu?

How do I check if GCC is installed or not?

To check that GCC is installed, you can display the version. In case you already have GCC installed globally, then you can go to the folder where the binary is and run gcc-11 (Homebrew GCC 11.1.0_1) 11.1.0 Copyright (C) 2021 Free Software Foundation, Inc.

What is GCC and how to use it?

It is an open source toolset for compiling source codes of C, C++, Objective-C, Fortran, Ada, Go and D programming languages. In this article, I am going to show you how to install GCC on Ubuntu and compile C and C++ programs.


1 Answers

My preferred method is to have a deb-src entry in /etc/apt/sources.list as e.g.

# Debian sources
deb-src http://ftp.us.debian.org/debian/ unstable main contrib non-free

I can then do apt-get source foo and fetch the appropriate package with its sources which will be unpackages. I typically add a local changelog entry (set apart by a revision number as 1.2-3local0) and rebuild. This sometimes entails building dependencies. It all depends...

I guess gcc-4.5 is currently in experimental as per this page so you would have to add experimental to the sources.list file as well. I have not used this but it should work too:

deb-src http://ftp.debian.org/debian experimental main
like image 50
Dirk Eddelbuettel Avatar answered Dec 06 '22 06:12

Dirk Eddelbuettel