Edit: Ok, so I should have been using g++ instead of gcc for the .cpp file. That's settled. New question though, how do I link files that I have included? Say if I write a program and I want to include curses.h, how do I compile that?
Everything below this is the original question.
Hi all. Up until this point I've always written and compiled my programs in Windows. I got a Macbook Pro a couple of months ago, and figure it's time to start programming in Unix. I'm not very advanced in terminal, so it took me a bit of time to try to even get to the proper directory. I finally got the commands correct to compile but I got errors on everything, including a hello world program!
Every time I try to compile something I get this:
Code:
/usr/bin/ld: Undefined symbols:
And a bunch of stuff depending on what I'm trying to compile
for
Code:
#include <iostream>
using namespace std;
int main( int argc, char *argv[] )
{
cout << "Hello World" << endl;
return 0;
}
I get this in the terminal:
Code:
current directory$ gcc -o helloworld helloworld.cpp
/usr/bin/ld: Undefined symbols:
std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
std::ios_base::Init::Init()
std::ios_base::Init::~Init()
std::cout
std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
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
I have no idea what most of this means. Is there a reason why such a simple program won't compile? I know it's probably something stupidly simple, but as I've never worked in this environment before, it's totally beyond me.
If anybody can offer some advice, or show me a good starters guide to writing/compiling c/c++ in *nix, that be great.
Thanks so much.
Ed