Possible Duplicate:
GCC linker can’t find standard library?
I am trying to mess with this C++ book I got for the holidays, I am coming from a limited understanding of python so this stuff is real strange to me.
I typed out this code from one of the first lessons into my text editor and saved it as a .cpp file.
#include <iostream>
int main()
{
std::cout << "Enter two numbers:" << std::endl;
int v1 = 0, v2 = 0;
std::cin >> v1 >> v2;
std::cout << "The sum of " << v1 << " and " << v2
<< " is " << v1 + v2 << std::endl;
return 0;
}
but my terminal gives this crazy output when i try to compile it, whats going on?
Raymond-Weisss-MacBook-Pro:c++ Raylug$ gcc prog2.cpp
Undefined symbols for architecture x86_64:
"std::basic_istream<char, std::char_traits<char> >::operator>>(int&)", referenced from:
_main in cckdLEun.o
"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> >&))", referenced from:
_main in cckdLEun.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(int)", referenced from:
_main in cckdLEun.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in cckdLEun.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in cckdLEun.o
"std::cin", referenced from:
_main in cckdLEun.o
"std::cout", referenced from:
_main in cckdLEun.o
"std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
_main in cckdLEun.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
_main in cckdLEun.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Raymond-Weisss-MacBook-Pro:c++ Raylug$