Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

gpp 5.2 or better, providing C++14 for Jessie ?

Sat Feb 18, 2017 6:46 pm

hello,
what must I do to install gpp 5.2 or better feat. C++14 for Jessie ?
I just purchased a C++ guide book which introduces especially to C++14 features and so requires 5.2 or better as stated in the preamble.

Will this 5.x version then also work trouble-free and out of the box with the current Raspi GPIO libs (wiringPi, pigpio) or will there be drawbacks to be considered?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sat Feb 18, 2017 9:39 pm

Stiller wrote:hello,
what must I do to install gpp 5.2 or better feat. C++14 for Jessie ?
I just purchased a C++ guide book which introduces especially to C++14 features and so requires 5.2 or better as stated in the preamble.

Will this 5.x version then also work trouble-free and out of the box with the current Raspi GPIO libs (wiringPi, pigpio) or will there be drawbacks to be considered?
I use GCC 6.3 on all my Pi's from the Pi Zero up to Pi3's. It works fine, fully supports C11, C++14, with some early support for C++17.

You need to compile it yourself which takes about 6 hours on a Pi3 - leave it overnight!

Do something like this for the Pi3, the "make -j5" takes most of the time:-

Code: Select all

wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.bz2
tar xf gcc-6.3.0.tar.bz2
cd gcc-6.3.0
contrib/download_prerequisites
mkdir obj
cd obj
../configure -v --enable-languages=c,c++ --with-cpu=cortex-a53 \
  --with-fpu=neon-fp-armv8 --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf

sudo dd if=/dev/zero of=/swapfile1GB bs=1M count=1024
sudo chmod 0600 /swapfile1GB
sudo mkswap /swapfile1GB
sudo swapon /swapfile1GB

make -j5
sudo make install
Last edited by jahboater on Sun Feb 19, 2017 12:59 pm, edited 1 time in total.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 8:27 am

jahboater wrote:
Stiller wrote:hello,
what must I do to install gpp 5.2 or better feat. C++14 for Jessie ?
I just purchased a C++ guide book which introduces especially to C++14 features and so requires 5.2 or better as stated in the preamble.

Will this 5.x version then also work trouble-free and out of the box with the current Raspi GPIO libs (wiringPi, pigpio) or will there be drawbacks to be considered?
I use GCC 6.3 on all my Pi's from the Pi Zero up to Pi3's. It works fine, fully supports C11, C++14, with some early support for C++17.

You need to compile it yourself which takes about 6 hours on a Pi3 - leave it overnight!

Do something like this for the Pi3, the "make -j5" takes most of the time:-

Code: Select all

get ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.bz2
tar xf gcc-6.3.0.tar.bz2
cd gcc-6.3.0
contrib/download_prerequisites
mkdir obj
cd obj
../configure -v --enable-languages=c,c++ --with-cpu=cortex-a53 \
  --with-fpu=neon-fp-armv8 --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf

sudo dd if=/dev/zero of=/swapfile1GB bs=1M count=1024
sudo chmod 0600 /swapfile1GB
sudo mkswap /swapfile1GB
sudo swapon /swapfile1GB

make -j5
sudo make install
hello,
thank you very much for your advice!
I actually have a Pi 2, not a Pi3, and my SD card' is of 32GB, but from NOOBS (I mention that because of the swap file).
So will your instruction work identically also for the my Pi 2 hardware, or has something to be changed for it?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 9:01 am

Stiller wrote:
he
thank you very much for your advice!
I actually have a Pi 2, not a Pi3, and my SD card' is of 32GB, but from NOOBS (I mention that because of the swap file).
So will your instruction work identically also for the my Pi 2 hardware, or has something to be changed for it?
If its a new Pi2 (v1.2) then yes, no change is needed, as its the same armv8 processor as a Pi3.
If its the old Pi2 (armv7) then I change the configure line to:-

Code: Select all

../configure -v --enable-languages=c,c++ --with-cpu=cortex-a7 \
  --with-fpu=neon-vfpv4 --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
It doesn't matter about NOOBS.
The swapfile takes 1GB. Its only needed for higher values of "make -j" probably 3 or more, I cant remember if you need the swap for -j2, but you definitely do not need it for make -j1 the default. Of course it builds pretty slowly with -j1! It only uses the swap for a brief period during the build.
(the -j argument for make tells it to run multiple compilations in parallel using the 4 cores of the Pi2/Pi3 but of course it takes more memory). If you just type "make" you don't need to bother with the swapfile at all, but it will probably take a day or more to build.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 11:35 am

it's the old pi 2, thank you!
I'll do it then that way tonight:

Code: Select all

# Pi 2 (old):
get ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.bz2
tar xf gcc-6.3.0.tar.bz2
cd gcc-6.3.0
contrib/download_prerequisites
mkdir obj
cd obj
../configure -v --enable-languages=c,c++ --with-cpu=cortex-a7 \
  --with-fpu=neon-vfpv4 --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf

sudo dd if=/dev/zero of=/swapfile1GB bs=1M count=1024
sudo chmod 0600 /swapfile1GB
sudo mkswap /swapfile1GB
sudo swapon /swapfile1GB

make -j5
sudo make install

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 12:11 pm

trying to download the tar file, there is the error:

Code: Select all

get ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.bz2

Code: Select all

get not found
what kind of command command is "get" and how to install it ?
perhaps wget instead?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 12:59 pm

Stiller wrote:trying to download the tar file, there is the error:

Code: Select all

get ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.bz2

Code: Select all

get not found
what kind of command command is "get" and how to install it ?
perhaps wget instead?
Oops sorry, it should be wget of course. My cut and paste missed!

You could just go to the gcc website and download it. https://gcc.gnu.org/

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 1:58 pm

ok, download seems to be ok
but then it seems to do nothing any more:

no screen message about tar and/or anything else.

I started downoload from /home/pi/
was that correct?
The gcc-6.3.0.tar.bz2 file is located there anyway.

Are your sure that these lines are completely ok?

Code: Select all

tar xf gcc-6.3.0.tar.bz2
cd gcc-6.3.0
contrib/download_prerequisites
mkdir obj
cd obj

edit, update:

now an error message:

Code: Select all

Segmentation fault
what does that mean?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 2:04 pm

Stiller wrote:ok, download seems to be ok
but then it seems to do nothing any more:
The tar xf may take a few minutes as there are quite a lot of files (over 100,000 of them) and the SD card is slow.
Use tar xvf if you want it to print out stuff as its going on.
I tend to run the commands one by one, not all as a script, so I can check each one has completed OK,
though it always works nowadays I should just put them all in script.
Just cut and paste each line onto the console.
Last edited by jahboater on Mon Feb 20, 2017 9:02 am, edited 1 time in total.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 2:08 pm

and what is it about the message "Segmentation fault" ?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 2:11 pm

Stiller wrote: I started downoload from /home/pi/
was that correct?
The gcc-6.3.0.tar.bz2 file is located there anyway.
You can download to anywhere you like that has enough space.
Then expand the tar file and it will create a directory called "gcc-6.3.0" which has a huge tree of files in it.
cd into that, and start doing the build.
now an error message:

Segmentation fault

what does that mean?
Thats bad - what command exactly was that.
Do the commands one by one.
Are you sure the download and tar xf completed. perhaps do "rm -rf gcc-6.3.0" and try again with tar xvf.
Last edited by jahboater on Sun Feb 19, 2017 2:14 pm, edited 1 time in total.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 2:14 pm

that segmantaion fault error was in the tar command.

I'll do it again.

About:

Code: Select all

cd gcc-6.3.0
contrib/download_prerequisites
"cd gcc-6.3.0" is clear, but what means
"contrib/download_prerequisites" ?
Is that a command? or is also for a cd ?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 2:24 pm

Stiller wrote:that was in the tar command
Never ever seen that before. Are you certain the download completed OK, you didn't break into it by any chance? Have you got enough disk space? Tar is a very reliable program, people have been using it for over 40 years. You don't have a fake, or faulty SD card have you?

Make sure you have a few GB (say 6GB*) of free space and try downloading again from here say:
ftp://ftp.mirrorservice.org/sites/sourc ... gcc-6.3.0/
Check with ls and cmp its the same file as you downloaded with wget. There are md5 and shar512 checksums you could check the download with.

* The build tree takes about 4.5GB plus 1GB of swap space - with a bit extra for luck!

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 2:38 pm

Stiller wrote:but what means
"contrib/download_prerequisites" ?
Is that a command? or is also for a cd ?
Its a command provided by GCC to download the source of the things like GMP and MPFR that the compiler uses. They get placed in the build tree and are automatically included in the build. Very useful as it ensures you have all the correct versions of the pre-requisites.
Just type its name and wait for it to finish.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 3:18 pm

alright, after downloading anew now it's very busy, unstoppable outputs by tar xvf.

I'll wait and see.

about the SD: as stated it's 32 GB, no big files on it, but no idea how much free space though. How would I know that?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 4:14 pm

Stiller wrote:alright, after downloading anew now it's very busy, unstoppable outputs by tar xvf.

about the SD: as stated it's 32 GB, no big files on it, but no idea how much free space though. How would I know that?
Should be plenty of space, try "df -h" too see how much there is.

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Sun Feb 19, 2017 4:35 pm

Stiller wrote:unstoppable outputs by tar xvf.
Let it finish without pressing any keys. You don't want to get a couple of hours into the build and then it fails because part of the source tree is missing!

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Mon Feb 20, 2017 8:55 am

hello,
it took some hours longer than expected, but this morning it was finished, no conspicious error messages, and g++ --version gives 6.3.0
so I think everything should be alright.
Thank you very much for your help!

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Tue Feb 21, 2017 4:14 pm

1 more question
having installed everything -
can now the
home/pi/gcc-6.3.0
Folder (created by tar) be completely deleted finally?

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Tue Feb 21, 2017 5:56 pm

Stiller wrote:1 more question
having installed everything -
can now the
home/pi/gcc-6.3.0
Folder (created by tar) be completely deleted finally?
Yes.
On my Intel PC with 16GB of memory, I untar it onto a ramdisk, do the build, then delete it all. Very fast and saves writes to the SSD!!

I presume you have checked it works and have tried -std=c++14 or -std=gnu++14

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Tue Feb 21, 2017 6:12 pm

thank you!

I tried a simple

#include <iostream>
using namespace std;
//...
cout << "Hello World" << endl;
//...

with the compile/build setting -std=c++14 in Geany, there was no compile error or warning, and it executed correctly - no C++14 specific cmd though (I don't know any yet).

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Tue Feb 21, 2017 6:22 pm

Stiller wrote: I just purchased a C++ guide book which introduces especially to C++14
Can I ask you a question?
What was the C++ book you mention?
Mine are all very old, including the first ever book by Stroustrup!

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Tue Feb 21, 2017 6:34 pm

it's a book in German, C++ eine Einführung, by Ulrich Breymann.
although I am not sure yet if all it's required and used libs and tools are compatible to the Pi and if even I am able to make them work, too.
First thing I needed additionally is cmake, which is actually a standard tool but I still was not capable of installing even that already (see my different thread).

jahboater
Posts: 5967
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Tue Feb 21, 2017 6:39 pm

Stiller wrote:it's a book in German, C++ eine Einführung, by Ulrich Breymann.
although I am not sure yet if all it's required and used libs and tools are compatible to the Pi and if even I am able to make them work, too.
First thing I needed additionally is cmake, which is actually a standard tool but I still was not capable of installing even that already (see my different thread).
OK thanks, I need an english one!
Do you really need cmake? Ordinary "make" is included on the Pi as standard, no need to install anything. (see man make).
It may or may not do all thats needed I don't know, but it is very powerful and guaranteed to be present on almost every unix or linux system.

You might find cmake 3.6.2 is good enough anyway. (I tried "sudo apt install cmake")

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: gpp 5.2 or better, providing C++14 for Jessie ?

Tue Feb 21, 2017 6:49 pm

I do not know in which extend the book will require it at all, but at least cmake is needed to build a library which is indispensible for a graphical lib for game programming: SFML.
I'm not so far advanced to understand how to build the SFML libs yet, but t least 1st of all cmake is required for that purpose, and then the next steps will have to be taken.
Actually the book seems to target different compiler Platforms, e.g. Windows and Mac, and some special/different Linux distributions for PCs. But I don't use PCs for programming, just the Pi and Arduinos.
And more over, NEVER Linux on either PC :roll:

Return to “C/C++”