5 Replies - 221 Views - Last Post: 02 March 2018 - 12:20 PM Rate Topic: -----

#1 Slyde   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 64
  • Joined: 11-February 18

How to Upgrade gcc/g++

Posted 02 March 2018 - 09:30 AM

My current gcc/g++ version on Linux Mint 18.3: gcc version 5.4.0

[email protected] ~ $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.9' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 

[email protected] ~ $ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.9' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)

The thing is, before I ran those version commands, I installed gcc 7 and g++ 7.
[email protected] ~ $ sudo apt-get install gcc-7 g++-7
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gcc-7 is already the newest version (7.1.0-10ubuntu1~16.04.york0).
Suggested packages:
  g++-7-multilib gcc-7-doc libstdc++6-7-dbg libstdc++-7-doc
The following NEW packages will be installed:
  g++-7 libstdc++-7-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 36.9 MB of archives.
After this operation, 182 MB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/jonathonf/gcc-7.1/ubuntu xenial/main amd64 libstdc++-7-dev amd64 7.1.0-10ubuntu1~16.04.york0 [1,455 kB]
Get:2 http://ppa.launchpad.net/jonathonf/gcc-7.1/ubuntu xenial/main amd64 g++-7 amd64 7.1.0-10ubuntu1~16.04.york0 [35.4 MB]
Fetched 36.9 MB in 1min 25s (432 kB/s)                                                                                                                                                                                                             
Selecting previously unselected package libstdc++-7-dev:amd64.
(Reading database ... 324815 files and directories currently installed.)
Preparing to unpack .../libstdc++-7-dev_7.1.0-10ubuntu1~16.04.york0_amd64.deb ...
Unpacking libstdc++-7-dev:amd64 (7.1.0-10ubuntu1~16.04.york0) ...
Selecting previously unselected package g++-7.
Preparing to unpack .../g++-7_7.1.0-10ubuntu1~16.04.york0_amd64.deb ...
Unpacking g++-7 (7.1.0-10ubuntu1~16.04.york0) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libstdc++-7-dev:amd64 (7.1.0-10ubuntu1~16.04.york0) ...
Setting up g++-7 (7.1.0-10ubuntu1~16.04.york0) ...


I've gone so far as to restart my computer. Even CodeBlocks shows my gcc version as 5.4. Nothing's broken (that I can see). CodeBlocks still compiles and code executes. What do I have to do make gcc-7 and g++-7 the default versions? I thought when version 7 installed, it would install over version 5.4.

This post has been edited by Slyde: 02 March 2018 - 09:40 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to Upgrade gcc/g++

#2 jimblumberg   User is offline

  • member icon

Reputation: 5487
  • View blog
  • Posts: 17,062
  • Joined: 25-December 09

Re: How to Upgrade gcc/g++

Posted 02 March 2018 - 09:50 AM

Well it looks like you should have two (or more) versions of gcc installed. You just need to figure out where gcc-7 was actually installed and then add the "new" compiler to your IDE.

Quote

What do I have to do make gcc-7 and g++-7 the default versions?

This depends on what (and where) you mean by default version. If you mean the default version for Code::Blocks then you will need to alter the compiler configuration inside Code::Blocks.

If you mean "system" default, I don't recommend you try to do this. The system default compiler should stay with the compiler that built the system, in this case 5.4.x. Trying to make the system use a new compiler without recompiling a good portion of the system can cause severe problems, let the system maintainers handle this job.

The first thing you need to do is find out where the new version of the compiler is installed. I would start by running updatedb from the command line, you'll need administrative privileges. Then once the db is updated try to "locate gcc-7", if found it should tell you where it is installed. You'll then use this information to set up the compiler in Code::Blocks. Start by copying the current version of gcc to a new instance (gcc-7). Then modify that new instance to change the locations of the tool chain executables.


Jim
Was This Post Helpful? 1
  • +
  • -

#3 Slyde   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 64
  • Joined: 11-February 18

Re: How to Upgrade gcc/g++

Posted 02 March 2018 - 09:58 AM

Thank you, Jim. I'm glad I asked and waited for a reply. Because I was sure about to tear up my OS again. I saw Debian 10 uses gcc7. So hopefully the soon-to-be-released Mint 19 (Tara) will be based off Deb 10 and use gcc7 by default rather than v5.4. Thanks again for your help. Much appreciated.
Was This Post Helpful? 0
  • +
  • -

#4 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 824
  • View blog
  • Posts: 3,334
  • Joined: 13-June 14

Re: How to Upgrade gcc/g++

Posted 02 March 2018 - 11:24 AM

Out of curiosity, what specifically do you need from gcc 7.x?
Was This Post Helpful? 0
  • +
  • -

#5 Slyde   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 64
  • Joined: 11-February 18

Re: How to Upgrade gcc/g++

Posted 02 March 2018 - 12:13 PM

I'm working through a well-maintained tutorial that shows some of the newer elements of C++17. The system version of 5.4.0 went up to C++14. So there really wasn't a "need" per se, just a want. Anyway, I have it all squared away now. My code compiles and executes, and I have C++17 capabilities.

I've read a lot of posts where the solution to a problem was achieved by the Op but no information given to those like me who were there to learn. So, aside from installing gcc-7 and g++-7, I also had to change three options in CodeBlocks, which in turn gave me the ability to have g++ follow the C++17 ISO C++ language standard.

I tried to add a 105 kb pic but got an error, so here's a link to it. I hope this helps someone.

This post has been edited by Slyde: 02 March 2018 - 12:14 PM

Was This Post Helpful? 1
  • +
  • -

#6 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 824
  • View blog
  • Posts: 3,334
  • Joined: 13-June 14

Re: How to Upgrade gcc/g++

Posted 02 March 2018 - 12:20 PM

That seems like a sensible reason. If it was for some esoteric advanced feature, I'd have been less convinced.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1