collect2: error: ld returned 1 exit status in c++ : <p>I have just switched to elementary os and installed sublime text editor. i wrote a basic hello world program in c++ to check the working. And I get this error.</p>

<pre><code>/tmp/cc3Pmvft.o: In function `main':
source.cpp:(.text+0xa): undefined reference to `std::cout'
source.cpp:(.text+0xf): undefined reference to `std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::operator&lt;&lt;  &lt;std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char const*)'
source.cpp:(.text+0x14): undefined reference to `std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::endl&lt;char, std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)'
source.cpp:(.text+0x1c): undefined reference to `std::ostream::operator&lt;&lt;(std::ostream&amp; (*)(std::ostream&amp;))'
/tmp/cc3Pmvft.o: In function `__static_initialization_and_destruction_0(int, int)':
source.cpp:(.text+0x4a): undefined reference to `std::ios_base::Init::Init()'
source.cpp:(.text+0x59): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
</code></pre>

<p>The hello world program was,</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main(){
     cout &lt;&lt; "Hello World!" &lt;&lt; endl;
     return 0;
}
</code></pre>

<p>I have  searched for answer in google and stackoverflow but couldn't find a solution. </p>
