g++ is missing when I use codeblocks - gcc

I'm using codeblocks with fedora-16. When I try to build it starts the build but then says `"/bin/sh: g++ command not found".
If I select compile, it compiles OK.
So looking at this site they say that gcc uses g++ so I tried "gcc -c this.c" and that worked.
Does anyone have a clue as to what is going on?

In order to compile .c and .cpp files in Fedora you need to install a compiler.
To install the gcc and g++ compilers, you will need the build-essential package. This will also install GNU make.
build-essential contains a list of packages which are essential for building Ubuntu packages including gcc compiler, make and other required tools.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ gcc -v
$ make -v
Now, you should able to compile software using C / C++ compilers.
To install the manpages for c and c++ development, install the manpages-dev package.
If
$ sudo apt-get install build-essential
doesn't work, try this:
su -
yum install make automake gcc gcc-c++ kernel-devel

Codeblock invokes g++ to link the libraries.

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.

How to install an old version of gcc alongside to the current one ? (and where to find it)

I would like to use an old version of gcc for one of my program (versions 3.* would be good), any idea how to do this?
Just compile and install it somewhere and optionally add its location to your $PATH. Do this in a directory where you downloaded gcc source code:
$ contrib/download_prerequisites
$ cd ..
$ mkdir objdir
$ cd objdir
$ ../gcc/configure --enable-languages=c --disable-multilib --prefix=$HOME/gcc-4.6.2 # modify option to suit your needs
$ make -j8
$ make install
Run it in $HOME/gcc-4.6.2:
$ usr/local/bin/gcc --version
(or use make install DESTDIR=<DIR> instead of --prefix)
If you are trying to install an older version of GCC that is no longer available (i.e. gcc 4.9) on ubuntu, you will not be able to download it directly.
Open your /etc/apt/sources.list file and append the following two lines:
deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
If this is your first time installing versioning on GCC run:
sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
Then in your terminal run the installation for any versions you are attempting to add. For example, if you want to install 4.9 (outdated) alongside gcc 7 and gcc 8 (not outdated):
Sources: How to install GCC Compiler on Ubuntu 18.04I need to install gcc4.9 on ubuntu 20.04|matlab mex
sudo apt update
sudo apt install gcc-4.9 g++ 4.9 gcc-7 g++-7 gcc-8 g++-8
Next, configure the GCC alternatives and their priority level:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 49 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
To compile your code using one of the newly installed versions, simply specify at compile time:
g++-4.9 <file_name>.cpp
To set your default GCC compiler use:
sudo update-alternatives --config gcc
Note: If this is your first time installing any version of GCC you may need to run
sudo apt install build-essential
sudo apt-get install manpages-dev
Sources: How to install GCC Compiler on Ubuntu 18.04
I need to install gcc4.9 on ubuntu 20.04|matlab mex

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

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

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