views:

1930

answers:

3

Hello,

I'm using Linux Ubuntu Intrepid Ibex and using as compiler the gcc, but when i try to compile me 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? Please Help Me!!

+3  A: 

Well, your gcc install is damaged, looks like.

Paul Nathan
How i can fix it????
Nathan Campos
no ubuntu by default does include gcc but not g++
flownt
+10  A: 

Do you have the build suite installed?

sudo apt-get --reinstall install build-essential

and compile C++ code with g++ command, not gcc.

Mehrdad Afshari
Thanks, now i'm compiling the project!!!!!!!!!!
Nathan Campos
Good luck ;)
Mehrdad Afshari
+1 for your comment because you are good pearson. Thanks!
Nathan Campos
A: 

Hello,

But when i try to compile my project g++ gave me this errors:

ubuntu@ubuntu-laptop:~/C++$ g++ ClientFile.cpp
ClientFile.cpp: In function ‘int main()’:
ClientFile.cpp:10: error: ‘ofstream’ was not declared in this scope
ClientFile.cpp:10: error: expected `;' before ‘outClientFile’
ClientFile.cpp:13: error: ‘outClientFile’ was not declared in this scope
ClientFile.cpp:15: error: ‘cerr’ was not declared in this scope
ClientFile.cpp:15: error: ‘endl’ was not declared in this scope
ClientFile.cpp:16: error: ‘exit’ was not declared in this scope
ClientFile.cpp:19: error: ‘cout’ was not declared in this scope
ClientFile.cpp:19: error: ‘endl’ was not declared in this scope
ClientFile.cpp:27: error: ‘cin’ was not declared in this scope
ClientFile.cpp:29: error: ‘outClientFile’ was not declared in this scope

And here is the code of the file:

#include <iostream>
#include <fstream> // Fluxo de arquivos

int main()
{
    //  Construtor ofstream abre arquivo
    ofstream outClientFile( "Clients.dat", ios::out );

    // Fecha o programa se não conseguir criar o arquivo
    if ( !outClientFile ) // Operador ! sobrecarregado
    {
       cerr << "File could not be opened" << endl;
       exit( 1 );
    } // Fim do if

    cout << "Enter the account, name, and balance." << endl
       << "Enter end-of-file to end the input.\n? ";

    int account;
    char name[ 30 ];
    double balance;

    // Lê conta, nome e saldo a partir de cin, então coloca no arquivo
    while ( cin >> account >> name >> balance )
    {
       outClientFile << account << ' ' << name << ' ' << balance << endl;
       cout << "?";
    } // Fim do while

    return 0; // Destruitor ofstream fecha o arquivo
} // Fim de main

What is wrong? Thanks!

Nathan Campos
This should be another question, but I think you're missing a `using namespace std;` after include lines.
Mehrdad Afshari
What, i'm not so familiar with C++?
Nathan Campos
`ofstream`, `cout`, `endl`, ... are defined in the `std` namespace. You should either include the namespace in the file by specifying `using namespace std;` or prefix every one of those with `std::`.
Mehrdad Afshari
Thanks, now it compile without errors! Thanks!
Nathan Campos