Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am new to ubuntu and I want to code in C++. I intalled g++ through software manager and after I installed netbeans to have a nice IDE to code in C++. Then I write this simple code:

#include <iostream>
//using namespace std;

int main(int argc, char**argv) {
    // Prints welcome message...
    std:: cout << "Welcome ..." << std::endl;

    // Prints arguments...
    if (argc > 1) {
        std::cout << std::endl << "Arguments:" << std::endl;
        for (int i = 1; i < argc; i++) {
            std::cout << i << ": " << argv[i] << std::endl;
        }
    }

    return 0;
}

When I built the code I got this error:

/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'

This meaning that isn't my code in error bu It seems that iostream refer something that is unknown.

Now, my question is: how I can check if gcc and g++ are installed correctly? And, if it is installed well, why g++ doesn't compile?

share|improve this question
    
sudo apt-get install g++-multilib This should solve your problem. –  c-qjv0xfi Dec 28 '13 at 22:24
1  
error is still present , I think it depends by netbeans IDE .I am going to close this question –  user228140 Dec 28 '13 at 23:41
1  
Can you try to compile with g++ from the terminal? –  c-qjv0xfi Dec 29 '13 at 4:00
add comment

1 Answer 1

up vote 2 down vote accepted

It is very strange. You need open "Project Properties" window and change Build|Linker|Tool from gcc to g++

Source: http://forums.netbeans.org/post-51209.html

p.s. I have no probs compiling code with g++, while I get same kind of errors trying with gcc.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.