PDA

View Full Version : gcc, c++ compiling problems




davidlt
Aug 29, 2007, 07:37 AM
naujas.cpp:
#include <iostream>

int main()
{
std::cout << "Hello World!";
return 0;
}

of course you can use "using namespace std;" and you don't need to write like this std::cout.

Compiling:
gcc -o naujas naujas.cpp

Problems:
macbook:~/sandbox marius$ gcc -o naujas naujas.cpp
/usr/bin/ld: Undefined symbols:
std::ios_base::Init::Init()
std::ios_base::Init::~Init()
std::cout
std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
___gxx_personality_v0
collect2: ld returned 1 exit status


For my eyes it looks like the problem is with std library, but I don't know much about C++. Any ideas how I could compile it? I would like to find out, I will be programming in C/C++ in University using Debian/Solartis.

By the way, I can compile C code with gcc using Mac.



dynetk
Aug 29, 2007, 08:14 AM
Try using g++ instead of gcc

davidlt
Aug 29, 2007, 08:38 AM
Worked just perfect, thanks for this one. But why gcc can't compile C++ code?

pilotError
Aug 29, 2007, 09:09 AM
Worked just perfect, thanks for this one. But why gcc can't compile C++ code?

because g c c = gnu C compiler