Question

I will work for a month in a computer that is not mine, thus returning it back as soon as I am done. However, I can be root.

The problem is that I can not run C++11. I am not interested in the latest compiler, just a compiler who can support some C++11 (for example, I do not care about regex).

I tried all these:

sudo yum install gcc-c++

which gives:

Loaded plugins: dellsysidplugin, kernel-module, refresh-packagekit Setting up Install Process Package gcc-c++-4.3.2-7.i386 already installed and latest version Nothing to do

sudo update-alternatives --config gcc

gives nothing

bash-3.2$ g++ --version

which gives:

g++ (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) Copyright (C) 2008 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.

yum groupinstall "Development Tools"

says all up to the latest version

Some compilation:

bash-3.2$ g++ px.cpp -std=c++0x -o px px.cpp:2:18: error: chrono: No such file or directory

What can I do? The problem lies on fedora 10? I do not know if I am allowed to update the OS of the computer (which is ancient, battery messages at start up, just to get a glance of it). Moreover, since it is ancient, I am afraid not to destroy it (by upgrading).

Was it helpful?

Solution

Simply download binutils and gcc and the other prerequisites sources as tarball. Unpack and compile to every directory you want. Compile takes maybe 10 minutes and you are finished. I have also a very! old suse linux with a wide variant of compilers in parallel.

Edit: add link to gcc wiki

http://gcc.gnu.org/wiki/InstallingGCC

BTW and not a real answer to the OP question but a fast solution:

What do you think about downloading fedora 20, burn a CD or use a big enough usb stick, boot from CD or usb stick and mount the volume on your laptop and have fun. In fedora 20 the gcc 4.8.2 is in. Should be an alternative from some quit tasks.

If you only want very small examples to run, you also can use a only compiler: http://www.compileonline.com/compile_cpp11_online.php for example. A lot more can be find by G* and others.

OTHER TIPS

Problem solved.

For the Others: It was needed to download and build last release.

After this, it's necessary to know where compiler is in order to use it instead of the old one:

  • It's possible to add the compiler path in $PATH (defined before the standard declaration).
  • Use full path when use the program.
  • other stuff that you have in mind (simlink etc).

I decided to write this answer, so that it has the complete answer.

You can't install the compiler by usual methods (e.g. sudo yum install gcc-c++), because, fedora 10 is too old. You have to manually download it and install it.

From gnu, download the compiler you want. I downloaded gcc-4.6.2.tar.gz (under gcc-4.6.2 folder).

Then, it's time to configure and build the compiler. Go in your desired directory and do the following (I just stayed in the Download folder):

note: this can take some time (the computer I am using is really old and took more than 45 minutes)

tar xzf gcc-4.6.2.tar.gz cd gcc-4.6.2 ./contrib/download_prerequisites cd .. mkdir objdir cd objdir $PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2 make make install

Source: gcc wiki (thanks to Klaus)

Then, in order to compile C++11, I had to provide the full path to the new compiler and add -static flag (Why?).

In my case, I would compile px.cpp file to px executable, like this:

/user/gsamaras/home/gcc-4.6.2/bin/g++ px.cpp -static -std=gnu++0x -o px

More methods can be found at Jepessen's answer and at this corner of stackoverflow.

Credits are to be given to Klaus and Jepensen, but I thought grouping all together might help the next guy (if any for fedora 10.. :P )

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top