Error When Compiling C++ File In GCC - c++

I'm using Linux Ubuntu Intrepid Ibex and using as compiler the gcc, but when I try to compile a C++ project file, the compiler give me this error:
ubuntu#ubuntu-laptop:~/C++$ gcc ClientFile.cpp
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
What is wrong?

Do you have the build suite installed?
sudo apt-get --reinstall install build-essential
and compile C++ code with g++ command, not gcc.

Well, your gcc install is damaged, looks like.

Related

MATLAB No supported compiler or SDK was found in mex_compile Linux

I had to downgrade my GCC to version 4.7 because I had this kind of problem when compiling matConvnet
Warning: You are using gcc version '5.4.0'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
So, I did the following steps to make GCC 4.7.0 the default compiler of my machine:
sudo apt-get install gcc-4.7
sudo rm /usr/bin/gcc
ln -s /usr/bin/gcc-4.7 /usr/bin/gcc
However, when I try to compile Matconvnet again I had the following error:
Error using vl_compilenn>mex_compile (line 434)
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016a/glnxa64.html.
Error in vl_compilenn (line 387)
parfor i = 1:numel(horzcat(lib_src, mex_src))
What I missed in my procedure?
EDIT: I realized that the problem is with the g++ compiler
when I do the mex -setup C++ command in MATLAB I have this error:
Error using mex
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016a/glnxa64.html.
When I do the which g++ command it returns me nothing. When I apt-get install g++ the following returns to me:
g++ is already the newest version (4:5.3.1-1ubuntu1).
What I can do to make MATLAB recognize my g++ compiler?
It's probably way to late for an answer, but when I had a similar problem, the following seemed to be the solution:
sudo apt-get install --reinstall gcc
sudo apt-get install --reinstall g++
Hope it helps everyone who stumbles upon this.

using g++ with -m32 on travis results in an error

I am installing these packages: g++-4.7 gcc-4.7-multilib and I set CXX to g++-4.7
I validate that the compiler is indeed 4.7 by issuing ${CXX} --version
after that I call cmake like this:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-m32" .
My project has only c++ source files so no need for C flags. The errors I get on travis are:
/usr/include/c++/4.7/cstdio:43:28: fatal error: bits/c++config.h: No such file or directory
any ideas? I have no problems using -m64
EDIT:
just tried also with g++-4.7-multilib (g++ instead of gcc) but still no luck - same error.
Seems like you ran into this: Missing include "bits/c++config.h" when cross compiling 64 bit program on 32 bit in Ubuntu
Make sure that you have the same versions of gcc, g++, gcc-multilib and g++-multilib installed and if that doesn't help, try adding -I/usr/include/c++/4.7/i686-linux-gnu to CXXFLAGS
I looked at the log and saw this...
Installing APT Packages (BETA)
Disallowing packages: g\+\+-4.7-multilib
If you require these packages, please review the package approval process at:
https://github.com/travis-ci/apt-package-whitelist#package-approval-process
turns out taht only for gcc 4.6 and 4.7 the package is not in the whitelist - other gcc versions have it... will request it.

installing gfortran in cygwin: gfortran: cyglto_plugin.dll not found

I'm trying to get the gfortran compiler with cygwin. When attempting to compile a hello world program, I get the following error:
gfortran: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
To install the compiler, I used the cygwin setup and selected
gcc-fortran: GNU compiler collection
libgfortran3: GCC fortran runtime library
I also mistakenly selected the toolchains for mingw, even though I don't have the mingw compiler (as far as I'm aware). g++, which I installed awhile ago, works fine.
What do I need to do to compile/find the library?
It is because of the gcc and gfortran versions are not same, try checking that. If so, do the following
$ apt-cyg remove gcc-fortran
$ apt-cyg install gcc-fortran

Compile OpenMP programs with gcc compiler on OS X Yosemite

$ gcc 12.c -fopenmp
12.c:9:9: fatal error: 'omp.h' file not found
#include<omp.h>
^
1 error generated.
While compiling openMP programs I get the above error. I am using OS X Yosemite. I first tried by installing native gcc compiler by typing gcc in terminal and later downloaded Xcode too still I got the same error. Then I downloaded gcc through:
$ brew install gcc
Still I'm getting the same error. I did try changing the compiler path too still it shows:
$ which gcc
/usr/bin/gcc
So how do I compile programs with gcc?
EDIT: As of 13 Aug 2017 the --without-multilib option is no longer present in Homebrew and should not be used. The standard installation
brew install gcc
will provide a gcc installation that can be used to compile OpenMP programs. As below it will be installed into /usr/local/bin as gcc-<version>. The current gcc version available from Homebrew (as of writing) will install as gcc-8. You can compile programs with OpenMP support using it via
gcc-8 -fopenmp hello.c
Alternatively you could put an alias in your .bashrcfile as
alias gcc='gcc-8'
and then compile using
gcc -fopenmp hello.c
Note: I'm leaving the original post here in case it is useful to somebody.
The standard gcc available on OS X through XCode and Clang doesn't support OpenMP. To install the Homebrew version of gcc with OpenMP support you need to install it with
brew install gcc --without-multilib
or as pointed out by #Mark Setchell
brew reinstall gcc --without-multilib
This will install it to the /usr/local/bin directory. Homebrew will install it as gcc-<version> so as not to clobber the gcc bundled with XCode.
I finally did some research and I finally came across a solution here: <omp.h> library isn't found in the GCC version (4.2.1) in Mavericks.
I got a new gcc complier from http://hpc.sourceforge.net/
Then I placed a new executable folder by
$ sudo tar -xvf gcc-4.9-bin.tar -C /
Later I switched to it by
export PATH=/usr/local/bin:$PATH that seemed to do the trick!

"make[2]: g++: Command not found" in Netbeans

I get the error message:
make[2]: g++: Command not found
which I know means it cannot find the C++ compiler. However, in Netbeans if I go to the configuration to choose my C++ compiler it shows the following being in /usr/bin:
g++4.6
g++4.7
g++4.8
but it doesn't have just g++.
Tried sudo aptitude install g++ but it didnt work.
If I do g++ --version I get:
The program 'g++' can be found in the following packages:
* g++
* pentium-builder
1) Verify you can run "g++" from the command line,
2) type whereis g++ to get the path,
3) Make sure you have the NetBeans C++ plugin installed
Go to Tools->Options->C++->Build Tools
4) Configure the path in NetBeans
Usually, /usr/bin/g++ is a symlink to some /usr/bin/g++-4.7 (or g++-4.8 etc...); just make it again (which is usually provided by the g++ virtual package on Debian or Ubuntu), e.g.
% sudo -s
# cd /usr/bin
# ln -sv g++-4.8 g++
Above % and # are shell prompts that you should not type.
Of course, don't forget the sudo apt-get install g++ etc...
BTW, you might put that link from $HOME/bin/g++ to /usr/bin/g++-4.8 and you don't need root permission for that.
(sometimes, these symlinks go indirectly thru /etc/alternatives etc...)
Your issue is a sysadmin issue; you should rather ask it (with a big lot more details) on askubuntu or superuser; it is off-topic on Stack Overflow.
BTW, NetBeans is not a compiler, but an editor (sometimes called IDE). You could use something better/simpler (e.g. emacs or vim) with e.g. make as a builder (to be run inside a terminal). Before using NetBeans ensure that g++ -v is working alone in some terminal