title: Problem occurred while compiling a cpp program in gcc
body: <p>My code is  </p>
  
  <pre><code>#include&lt;iostream&gt;   
  
  using namespace std;  
  int main()  
  {  
     cout &lt;&lt;"hi";  
     return 0;  
  }
  </code></pre>
  
  <p>I compile it with:</p>
  
  <pre><code>gcc d.cpp -o d  
  </code></pre>
  
  <p>Error as follows  </p>
  
  <pre><code>Undefined                       first referenced
   symbol                             in file
  std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::operator [](unsigned int) const/var/tmp//ccyDVhhA.o
  std::cout                           /var/tmp//ccyDVhhA.o
  std::ios_base::Init::~Init()        /var/tmp//ccyDVhhA.o
  std::ios_base::Init::Init()         /var/tmp//ccyDVhhA.o
  __gxx_personality_v0                /var/tmp//ccyDVhhA.o
  std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::operator&lt;&lt; &lt;std::char_tr aits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char const*)/va r/tmp//ccyDVhhA.o
  std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::size() c onst/var/tmp//ccyDVhhA.o
  ld: fatal: Symbol referencing errors. No output written to d
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>What is the mistake in the above code?</p>