cc1plus: error: unrecognized command line option ‘-std=c++11’ Ubuntu gcc 4.7 - gcc

I am trying to compile some c++11 code on ubuntu 12.04. After invoking my makefile I got
cc1plus: error: unrecognized command line option ‘-std=c++11’
Ubuntu gcc 4.7. Fine, so I ran
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7
Ran it again, and still the same problem. Great.So then I tried changing the symlink of gcc from gcc4.6 to 4.7. After doing this, it then went and complained about not being able to find g++. So I then ran
sudo apt-get update
sudo apt-get install build-essential
Still no luck. When I typed g++, I just got
The program 'g++' can be found in the following packages:
*g++
*pentium_builder
Try: sudo apt-get install <selected package>
So I then tried
sudo apt-get install pentium_builder
Now I get
Unable to exec g++.real: No such file or directory
How I can compile c++11 code?

Last time I tried, the following worked for me for installing and setting g++ 4.8 as default:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
It seemed painless, and I was able to choose which gcc/g++ version to use without manually setting up symlinks. I suspect this would work for gcc 4.7 as well.

Add the following to your Makefile:
PROJECT_CFLAGS = -std=c++0x

Related

cilk.h: No such file or directory

I compile in Ubuntu 20.04 with gcc 7.5.0 and g++ 7.5.0(supporting cilk plus), but the error says that 'cilk/cilk.h: No such file or directory'the error is shown in the picture
Anybody could help me with the situation? Thanks a lot!
Your compiler still doesn't support cilkplus, just install it via apt-get install:
sudo apt-get install -y libcilkrts5
there you go,
UPDATE: Cilk is not supported with the gcc package on ubuntu 20.04,
to have cilk on ubuntu 20.04 you have to install gcc version < 7 , by the following instruction it's possible to install gcc-6 g++6 on ubuntu 20.04,
sudo vim /etc/apt/sources.list
add "deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe" to file
sudo apt update
sudo apt-get install gcc-6 g++-6 -y
check by gcc -v if you have downgraded correctly the gcc version Then the cilk extension should work.

LinuxBrew does not install latest version of gcc?

When I do g++ --versionon my Linux Ubuntu I get g++ (Home-brew GCC 5.5.0_7) 5.5.0. This was installed via brew install gcc.
As the latest version of gcc is 10.2, why has brew not installed this version?
I had also tried
sudo apt update
sudo apt install build-essential
sudo apt install gcc-9and
gcc --version
but it did not change the version. Any advice?
Also, when I try to run an installation script I get the following error
error: command 'home/linuxbrew/.linuxbrew/bin/g++ failed with exit code 1
but
which gcc
gives
/home/linuxbrew/.linuxbrew/bin/g++
so I am not sure what happened.

make all fatal error, when i am compiling Makefile

I am getting error as shown below while running make all command.
fatal error: google/protobuf/arena.h: No such file or directory
compilation terminated.
cd ~/caffe
sudo make clean
sudo apt-get install libboost-all-dev
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler
pip install protobuf
sudo make all
sudo make test
sudo make runtest
Either you don't have protobuf installed or it is outdated. To install, run the following command
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
In case it is outdated, you need to compile protobuf from the source.

how can i solve the gcc problems in Debian ? when i am apt-get install gcc find one qustions?

I'm using gcc to compile files in Debian terminal,
but I get back : zsh: command not found: gcc
So I've tried sudo apt-get install gcc.
> The following packages have unmet dependencies:
> gcc :
> Depends:gcc-4.7(>=4.7.2-1~) but it is not going to be installed
> Recommends: libc6-dev but it is not going to be installed or libc-dev
Try installing GCC and its dependencies with this package:
sudo apt-get install build-essential
Run the following command:
aptitude -f install
Then install build-essantial it will install all the dev-tools:
aptitude install build-essential

Upgrade GCC 4.6.3 on Ubuntu 12.04 to 4.8.2

I'm about to update default GCC (version 4.6.3) shipped by Ubuntu 12.04 to 4.8.2, though the compilation requires a standalone C++ compiler
admin#ubuntu: /usr/local/gcc_build$ sudo make
ends up with
configure: error: C++ compiler missing or inoperational
make[2]: *** [configure-stage1-libcpp] Error 1
Therefore I turn to the process of g++ installation with a preference to the latest version, which means that I would like to compile from source directly rather than apt-get. But seriously, I can't find the source anyway!(O_o). On the other hand, does the source of GCC also come along with that of g++ in the tar file I downloaded, or not? Thanks.
PS: problem remains unsolved with admin#ubuntu: /usr/local/gcc_build$ /home/admin/gcc-4.8.2/configure --enable-languages=c,c++
Add the ppa by
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
Install g++ and gcc (version 4.8)
sudo apt-get update; sudo apt-get install gcc-4.8 g++-4.8
Run the following commands one by one,
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
That's it you are done!
You can easily compile the sources.
The following commands worked for gcc 4.7. They should be fine for gcc 4.8 as well:
sudo apt-get install libmpfr-dev libgmp3-dev libmpc-dev flex bison
svn checkout svn://gcc.gnu.org/svn/gcc/trunk
cd trunk
./configure --prefix=/opt/gcc-4.8.2/usr/local/gcc-4.8.2 --enable-languages=c,c++
make
make install
The compiler will be placed in the /opt/ directory, so you have to use it from there.
Do you want to compile it yourself ? If not, there is a PPA, described here

Resources