title: C++ linking error upon using "string"
body: <p>I'm working on a hobby side mini project in C++ and I have the following error upon running my binary.</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::__init(char const*, unsigned long)", referenced from:
        recv_line(int) in networking.o
  ld: symbol(s) not found for architecture x86_64
  </code></pre>
  
  <p>I have a file networking.cpp which has uses an instance of "std::string". I have the following contents inside my networking.h</p>
  
  <pre><code>#ifndef _NETWORKING_H
  #define _NETWORKING_H
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  #include &lt;unistd.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;netinet/in.h&gt;
  
  #define DELIMITER '\n'
  
  std::string recv_line(int sockfd);
  #endif
  </code></pre>
  
  <p>Inside networking.cpp I merely have :-</p>
  
  <pre><code>std::string recv_line(int sockfd) {
  return "";
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>[EDIT]</p>
  
  <p>I'm making the file as follows :-</p>
  
  <pre><code>% cat Makefile
  CXX=g++
  
  blah: main networking
      $(CXX) main.o networking.o -o blah -v
  main:
      $(CXX) -c main.cpp
  networking:
      $(CXX) -c networking.cpp
  % make
  </code></pre>
  
  <p>The version of g++ seems to be :-</p>
  
  <pre><code>% g++ --version
  Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
  Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  Target: x86_64-apple-darwin13.0.0
  Thread model: posix
  </code></pre>