Emacs errors with code that works in IDE's

Just starting with programming and I'd like to use Emacs (on Linux), the reason for this is that I'm reasonably familiar with Emacs as a text editor and I'm comfortable with it. I entered the simplest code I could possibly think of:-

#include <iostream>

using namespace std;

int main()
{
std::cout<<"Emacs is the best";
return 0;
}

and I got back:-
/tmp/ccxD67Ki.o: In function `main':
code.cc:(.text+0x14): undefined reference to `std::cout'
code.cc:(.text+0x19): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccxD67Ki.o: In function `__static_initialization_and_destruction_0(int, int)':
code.cc:(.text+0x41): undefined reference to `std::ios_base::Init::Init()'
code.cc:(.text+0x46): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccxD67Ki.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

The thing is I then copied and pasted this into Code::blocks and it ran fine!
Did you use gcc instead of g++? Tsk. ;D

-Albatross
Topic archived. No new replies allowed.