Page 1 of 1

C++ No Such File or Directory

Posted: Sun Mar 09, 2014 6:13 pm
by LyleGomera
This is my first time posting on this great forum, so hi everyone!

Now let's get to business. I'm trying to compile code with gcc, but I keep getting the error in the title. I tried #include <iostream>, #include <stdio.h>. I think I might need to put the headers/libraries in a place that the compiler can find them. But, I don't know what to put or where to put it. Thank you!

Code: Select all

la@lac ~ $ pwd
/home/la
la@lac ~ $ cd Desktop/CCPP/
la@lac ~/Desktop/CCPP $ gcc test.cpp
gcc: error trying to exec 'cc1plus': execvp: No such file or directory

Re: C++ No Such File or Directory

Posted: Sun Mar 09, 2014 7:13 pm
by jahid
if you are doing it through command line, then you may have mistaken to specify the correct path for the source file.

Re: C++ No Such File or Directory

Posted: Sun Mar 09, 2014 9:19 pm
by dagon
LyleGomera wrote:$ gcc test.cpp
For C++ projects you need to call the 'g++' compiler.
Try:

Code: Select all

g++ test.cpp

Re: C++ No Such File or Directory

Posted: Sun Mar 09, 2014 9:53 pm
by LyleGomera
That worked. Thank you both.

Re: C++ No Such File or Directory

Posted: Mon Mar 10, 2014 5:32 am
by jahid
I didn't see your last edit, which says the path is correct but the compiler is not.
gcc stands for GNU C compiler and g++ stands for GNU C++ compiler. so if you are going to compile a cpp file then certainly you will need to use g++ instead of gcc.