title: Undefined reference to my function
body: <p>I have some trouble with building the part of my project. Here it is:<br>
  <strong>utility.h</strong>:  </p>
  
  <pre><code>#ifndef UTILITY_H
  #define UTILITY_H
  
  #include &lt;boost/array.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;openssl/md5.h&gt;
  #include &lt;string&gt;
  
  namespace utility {
      typedef boost::array&lt;unsigned char, MD5_DIGEST_LENGTH&gt; md5sum;
      typedef boost::shared_ptr&lt;md5sum&gt; md5sum_ptr;
  
      ...
  
      md5sum_ptr calculate_md5(const std::string&amp; full_path);
  };
  
  #endif //UTILITY_H
  </code></pre>
  
  <p><strong>utility.cpp</strong>:  </p>
  
  <pre><code>#include "utility.h"
  
  using namespace utility;
  
  ...
  
  md5sum_ptr calculate_md5(const std::string&amp; full_path) {
      md5sum_ptr md5(new md5sum);
      std::ifstream in(full_path);
      std::string content;
      in &gt;&gt; content;
      MD5((unsigned char*)content.data(), content.size(), md5-&gt;data());
      return md5;
  }  
  </code></pre>
  
  <p><strong>cdaemon.cpp</strong></p>
  
  <pre><code>void CTCPConnection::handle_read_filename(ECommand command, EDataType datatype,
                        const boost::system::error_code&amp; ec) {
      ...
          case ECommand::GET_MD5:
              _send_container&lt;md5sum&gt;(*(calculate_md5(filename)));
              async_write(m_socket, m_writebuf,
                      boost::bind(&amp;CTCPConnection::handle_write_response, shared_from_this(),
                      placeholders::error));
              break;
          ...
      }
  }  
  </code></pre>
  
  <p><strong>Makefile:</strong></p>
  
  <pre><code>CC=g++
  override CFLAGS+=-c -std=c++11 -Wall -Wextra -Werror
  override LFLAGS+=-lboost_log -lpthread -lboost_system -lboost_thread -lcrypto
  
  server: servermain.o cdaemon.o
      $(CC) ../build/datatype.o ../build/utility.o build/servermain.o build/cdaemon.o -o build/frtpdaemon $(LFLAGS)
  servermain.o: main.cpp
      $(CC) $(CFLAGS) main.cpp -o build/servermain.o
  cdaemon.o: cdaemon.cpp
      $(CC) $(CFLAGS) -DBOOST_LOG_DYN_LINK cdaemon.cpp -o build/cdaemon.o   
  </code></pre>
  
  <p>When I try to build server, I get linker error:</p>
  
  <pre><code>build/cdaemon.o: In function `CTCPConnection::handle_read_filename(utility::ECommand, utility::EDataType, boost::system::error_code const&amp;)':
  cdaemon.cpp:(.text+0x127c): undefined reference to `utility::calculate_md5(std::string const&amp;)'  
  </code></pre>
  
  <p>I have already tried to google the solution, but all what I could find were suggestions to change the order of <em>../build/utility.o</em> and <em>build/cdaemon.o</em>. That didn't help me.</p>