"undefined reference to `std::ios_base::Init::Init()" while compiling a hello world in netbeans

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?

3

1 Answer

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

Source:

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like