"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...
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?
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.