Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

davidlt

macrumors member
Original poster
May 22, 2007
56
0
Lithuania
naujas.cpp:
Code:
#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:
Code:
gcc -o naujas naujas.cpp

Problems:
Code:
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.