How to update gcc ubuntu

How to update gcc ubuntu

Installing newer GCC versions in Ubuntu

It is often useful to have installed never versions of the compiler in our systems as they often provide better performance and extended features, such as support for newer language features and better debugging information. In the case of ubuntu the new GCC stable packages can be obtained from the Ubuntu Toolchain PPA.

To install them add the ppa repository and update the APT database:

Then install the desired GCC and G++ versions. At the moment of writing this page the latest available version is 7.2.0 (that correspond to the packages gcc-7 g++-7). Check if newer versions are available.

Now the different compiler versions are available in the system by using different command names (that is, gcc-5, gcc-6, etc.), but the default version, the one that is executed with the command gcc, will still be the previous one. To change the default version executed with the gcc command we have to configure the alternatives in the system. First lets remove any previous configuration with:

Which can show the error update-alternatives: error: no alternatives for gcc if no previous alternatives were configured. The configure the alternatives modifying it accordingly to the versions available on your system. Each alternative has a priority associated with it. When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority.

Once the different alternatives for the gcc package have been created then it can be configured with:

And a menu similar to this will appear. Select, for example, the option 3 to set as default gcc-7 instead of gcc-5:

Then test the version executed with the gcc command:

How to update gcc to the latest version(in this case 4.7) in Ubuntu 10.04?

I have Ubuntu 10.04 32-bit with gcc 4.4.3 currently installed on it. I want to upgrade it to gcc/g++ 4.7 (I am looking for C++ 0x support)

How to update using Ubuntu Package Manager:

As a second option I downloaded the latest gcc snapshot file from:

on this package build and install it from source?

5 Answers 5

Add the toolchain ppa test repository, then do apt-get update, and apt-get dist-upgrade

Then, invoke it with:

For the second part of the question, the answer is «yes, sort of». If you really want to do that (i.e. installing the gcc-snapshot package isn’t enough) then you’ll need to install the dependencies:

Then, find the correct configure options:

(and modify the install path etc.)

Then, build like this:

10.04 LTS

Use the following command to install add-apt-repository:

Then add the tooclain ppa test repo as described for 12.04 LTS.

How to install gcc 4.8 on Ubuntu 10.04:

Verify gcc version with:

How to compile the latest gcc:

What the script above does is:

BTW. If you are running this script on a low-end VPS with little RAM space, remember to allocate enough swap space just before you run gcc compilation/installation script:

How to update gcc ubuntu. Смотреть фото How to update gcc ubuntu. Смотреть картинку How to update gcc ubuntu. Картинка про How to update gcc ubuntu. Фото How to update gcc ubuntu

Not the answer you’re looking for? Browse other questions tagged 10.04 gcc or ask your own question.

Linked

Related

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

My Public Notepad

Bits and bobs about computers and programming

Pages

Monday, 23 March 2020

Upgrading GNU C/C++ compilers on Ubuntu

//CXX compiler
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++

When I tried to use C++17 header:

fatal error: filesystem: No such file or directory

. although I have in CMakeLists.txt:

Let’s just check my current GCC binary path by following symlinks:

18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Also, the following command would not return anything:

I have GCC version 7.5.0 and want to upgrade it to 8.0.

$ sudo apt install gcc-8 g++-8

Reading package lists. Done
Building dependency tree
Reading state information. Done
The following package was automatically installed and is no longer required:
libllvm8
Use ‘sudo apt autoremove’ to remove it.
The following additional packages will be installed:
cpp-8 libasan5 libgcc-8-dev libstdc++-8-dev libubsan1
Suggested packages:
gcc-8-locales g++-8-multilib gcc-8-doc libstdc++6-8-dbg gcc-8-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan5-dbg liblsan0-dbg
libtsan0-dbg libubsan1-dbg libmpx2-dbg libquadmath0-dbg libstdc++-8-doc
The following NEW packages will be installed
cpp-8 g++-8 gcc-8 libasan5 libgcc-8-dev libstdc++-8-dev libubsan1
0 to upgrade, 7 to newly install, 0 to remove and 31 not to upgrade.
Need to get 27.7 MB of archives.
After this operation, 113 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 cpp-8 amd64 8.3.0-26ubuntu1

18.04 [7,224 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libasan5 amd64 8.3.0-26ubuntu1

18.04 [366 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libubsan1 amd64 8.3.0-26ubuntu1

18.04 [122 kB]
Get:4 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgcc-8-dev amd64 8.3.0-26ubuntu1

18.04 [2,306 kB]
Get:5 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 gcc-8 amd64 8.3.0-26ubuntu1

18.04 [8,038 kB]
Get:6 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 libstdc++-8-dev amd64 8.3.0-26ubuntu1

18.04 [1,533 kB]
Get:7 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 g++-8 amd64 8.3.0-26ubuntu1

To verify installation we can use:

$ which gcc-8
/usr/bin/gcc-8

$ which g++-8
/usr/bin/g++-8

gcc and g++ symlinks are not updated automatically, they are still pointing to GCC v7:

We can update them manually to point to GCC v8.

Let’s do it for gcc first:

Let’s verify the symlink:

Let’s do it for g++ now:

With CMakeLists.txt changes:

NOTE: target_link_libraries() must come after add_executable()

Mead’s Guide to Upgrading GCC and Clang on Linux

Linux Mint 17 (including 17.1, 17.2, and 17.3) comes with GCC 4.8. To be exact, Linux Mint 17.3 comes with 4.8.4. If you need a later version of the compilers, you can either upgrade the entire distribution to Linux Mint 18.x or install newer versions of GCC alongside of the existing 4.8 version.

Upgrading Mint 17.x to 18.x is straight-forward, although I would recommend a fresh install of 18.x as sometimes the upgrade process doesn’t work as seamless as it should. Installing other versions of the compiler is a little more involved, but it’s a good way of keeping your existing (and functional) Mint 17.x system going. This page will demonstrate how to install newer versions of GCC and Clang.

Most of the work will be done from the command line, as that is the simplest way of doing it. You can just simply copy and paste the command lines listed below into a terminal. This document assumes that you have an up-to-date version of Linux Mint 17.x currently running on your system. It also assumes that you have GCC version 4.8.x and Clang version 3.5. (The default version of Clang is 3.4.) By default gcc is installed but you may have to install g++ manually:

I chose version 3.5 because this will co-exist with Clang version 3.8 nicely. I have discovered (through trial and error) that earlier versions of Clang are removed when installing Clang 3.8. I wanted to keep the older version around because sometimes I like to see how newer versions differ from older versions in the warnings they produce.

I will be updating GCC and Clang on version 17.3 of Linux Mint. To find out which version of GCC is currently enabled, just provide the --version option to gcc:

gcc: (shows version 4.8 and support programs)

OK, so we’ve got a system that has older versions of the compilers installed. Now, it’s time to install newer ones, but we also want to keep the older versions. By default, Linux Mint (as well as other distributions) tries to keep the major versions of software the same throughout the life-cycle of the distribution. This means that, since Mint 17 shipped with version 4.8 of GCC, it will stay at that version with the 17.x versions.

Version 5.x of GCC may be radically different than the 4.x series, so it won’t go into Mint until version 18 of Linux Mint. So, if you want to «get ahead» and install versions that are significantly different (newer), you have to do so manually.

Adding a repository

You simply install it like any other package:

Starting with version 5 of GCC, the version numbering scheme has changed somewhat. You no longer install gcc-5.1 or gcc-5.2. Instead, you simply install gcc-5, and whichever version is the latest one, that’s what you get. This means that you won’t see a third number in the versioning (e.g. 4.8.4). In the old system, going from 4.8.2 to 4.8.4 meant it was a trivial update (small changes, no new features). Going from 4.8 to 4.9 was consider non-trivial. In the new scheme, going from 5.1 to 5.2 is considered trivial. For non-trivial changes, the version will go from 5.x to 6. This means the first number is going to change more rapidly now. In fact, version 6 of GCC is already available.

Installing Clang 3.8

To use version 5 of gcc, you have to type gcc-5. This is all fine and good, but it’s tedious and if you have makefiles that assume gcc (which most do), this won’t work very well. We need to do a few things to allow us to easily switch between GCC and Clang versions as well as just typing the shorter form without explicitly stating the version.

Managing Multiple Versions

I mentioned above that there are lots of ways that you can manage multiple versions of a program. This could be by renaming files (not an ideal solution) or manually creating symbolic links (not a bad idea). Linux has a mechanism already in place to deal with just this situation. It calls multiple versions alternatives. All of the details about how this mechanism works is well beyond the scope of this little tutorial, but I’ll give you a brief introduction.

If you look in /etc/alternatives/ you will probably see lots (maybe hundreds) of links. Here are a few from the Linux Mint 17.3 system I’ve been using for this tutorial (there are actually about 200 links):

Managing all of these alternative links (pointers) is done by a program called, appropriately enough, update-alternatives. There are lots of options with this program, but I’m just going to cover the basics so you can use it effectively. To see what alternatives are available for the FTP program (ftp), just type:

Now, I could do the same thing with g++, as well. But, I don’t really want to use two different versions of gcc and g++ at the same time (e.g. gcc-4.8 and g++-5). I want them to be synchronized so that if I change gcc, then g++ will also change. This is the command to do that:

(When configured for version 4.8)

Note: If you run

If your system already has GCC 5 installed and you’d like to upgrade to GCC 7.x, there is a new script: install-gcc7.sh. You will have to download it and make it executable.

It’s similar to the script above, but installs version 7.x instead. It also doesn’t include Clang in the installation. If you’ve already run the above script, you don’t need the first line in the new script:

You can probably use this script to install any version of GCC (6, 7, 8, etc.) in the future simply by changing the appropriate lines.

Note: This procedure will not remove version 5.x from your computer. It will install version 7.x alongside of version 5.x. This means that you can switch between the two versions at any time using the command:

The previous section showed you how to install version 7.x of the GNU gcc compiler. It turns out, it’s trivial to install other later versions as well. I’ve updated the script: install-gcc-all.sh to install versions 6, 7, 8, 9, 10, and 11. If you don’t want to install and configure all of those compilers, just comment out the lines that you don’t want. (To comment out a line, just put a # in front of it.)

The script looks like this below. Note that some of the older compilers may not be available from the original locations. If you don’t want the 32-bit versions, just remove all references to «multilib» files.

To change the version of the compiler you want to use, just run the command:

If you don’t use VirtualBox, you can ignore this section.

For example, one of my systems runs Linux Mint 17 (Qiana). It’s been running just fine for years, although it’s getting a little old and at some point it will no longer be supported. I update/upgrade my system every so often like this:

None of the «solutions» I found on the Internet solved the problem. The fix for me was to simply switch the version of gcc to the original version temporarily by running:

This was just a quick introduction to installing newer versions of the compilers, as well as using update-alternatives to manage them. For more information, follow these links:

Программирование, настройка и администрирование CAD систем

Программирование, настройка и администрирование CAD систем

воскресенье, 29 сентября 2013 г.

Установка более новых версий компиляторов gcc и g++

GCC now uses C++ as its implementation language. This means that to build GCC from sources, you will need a C++ compiler that understands C++ 2003.

реализация GCC теперь полностью переписана на C++. Причины принятия такого решения перечислены здесь в разделах Background и Rationale. Состояние поддержки стандарта C++11 в GCC 4.8 обозначено здесь. О поддержке стандарта C11 можно почитать тут. Поскольку меня весьма интересует C++11 (читаю это), то захотелось поставить наиболее свежую версию компилятора.

1. Установка gcc 4.8.1 (компилятор C)

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-4.8

После успешной установки gcc 4.8.1, необходимо удалить gcc и g++ из списка приложений, используемых по умолчанию:

Назначаем gcc 4.8.1 компилятором, используемым по умолчанию:

Источник обозначенной выше информации здесь. Теперь нужно обновить и компилятор g++ (см. след. раздел).

2. Установка g++ 4.8.1 (компилятор C++)

После обновления gcc приступаем к обновлению g++:

Всё. После обновления системы проверяем версии компиляторов:

Т. о. всё прошло успешно.

Примечание: если не выполнять действий, описанных в разделе 2, то для g++ результат был бы иным:

gcc version 4.6.3

т. е. обновился бы только компилятор gcc, а g++ остался бы старым.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *