title: undefined reference to std::ios_base::Init::Init()
body: <p>I'm working on learning OOP with C++ and having a problem. I'm sure its a memory allocation problem but cant seem to get my head around it. Any help will be greatly appreciated.</p>
  
  <p>My Client Code</p>
  
  <pre><code>    #include &lt;iostream&gt;
      #include "Box.cpp"
  
      using namespace std;
  
      int main(){
          Box *box = new Box;
          return 0;
      }
  </code></pre>
  
  <p>My Box Class...</p>
  
  <pre><code>    #include &lt;iostream&gt;
  
      using namespace std;
  
      class Box{
  
          private:
              double width;
              double height;
              double perimeter;
              double area;
  
  
          public:
              Box(){
                  cout &lt;&lt; "Box created" &lt;&lt; endl;
              }
  
              ~Box(){
                  cout &lt;&lt; "Box Destroyed" &lt;&lt; endl;
              }
  
              double getWidth(){
                  //
                  return this-&gt;width;
              }
  
              double getHeight(){
                  //
                  return this-&gt;height;
              }
  
              double getArea(){
                  //
                  return this-&gt;area;
              }
  
              double getPerimeter(){
                  //
                  return this-&gt;perimeter;
              }
  
              void setWidth(double w){
                  //
                  this-&gt;width = w;
                  if(!this-&gt;height){
                      computeSetArea(this-&gt;width, this-&gt;height);
                      computeSetPerimeter(this-&gt;width, this-&gt;height);
                  }
              }
  
              void setHeight(double h){
                  //
                  this-&gt;height = h;
                  if(!this-&gt;width){
                      computeSetArea(this-&gt;width, this-&gt;height);
                      computeSetPerimeter(this-&gt;width, this-&gt;height);
                  }
              }
  
          private:
              void computeSetArea(double w, double h){
                  //
                  this-&gt;area = w*h;
              }
  
              void computeSetPerimeter(double w, double h){
                  //
                  this-&gt;perimeter = (w * 2) + (h + 2);
              }
      };
  </code></pre>
  
  <p>I use gcc and execute:</p>
  
  <pre><code>    gcc Box.cpp client.cpp -o mainfile
  </code></pre>
  
  <p>After such I receive this error.</p>
  
  <pre><code>/tmp/ccaVb21k.o: In function `__static_initialization_and_destruction_0(int, int)':
  Box.cpp:(.text+0x1d): undefined reference to `std::ios_base::Init::Init()'
  Box.cpp:(.text+0x22): undefined reference to `std::ios_base::Init::~Init()'
  /tmp/ccaVb21k.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
  /tmp/ccjtbzi4.o: In function `main':
  client.cpp:(.text+0x14): undefined reference to `operator new(unsigned int)'
  client.cpp:(.text+0x3f): undefined reference to `operator delete(void*)'
  /tmp/ccjtbzi4.o: In function `__static_initialization_and_destruction_0(int, int)':
  client.cpp:(.text+0x6c): undefined reference to `std::ios_base::Init::Init()'
  client.cpp:(.text+0x71): undefined reference to `std::ios_base::Init::~Init()'
  /tmp/ccjtbzi4.o: In function `Box::Box()':
  client.cpp:(.text._ZN3BoxC1Ev[Box::Box()]+0x11): undefined reference to `std::cout'
  client.cpp:(.text._ZN3BoxC1Ev[Box::Box()]+0x16): 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*)'
  client.cpp:(.text._ZN3BoxC1Ev[Box::Box()]+0x1e): 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;)'
  client.cpp:(.text._ZN3BoxC1Ev[Box::Box()]+0x26): undefined reference to `std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;::operator&lt;&lt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; (*)(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;))'
  /tmp/ccjtbzi4.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
  /tmp/ccjtbzi4.o:(.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'
  collect2: ld returned 1 exit status
  </code></pre>