title: No Idea Why I'm getting std::__1 Undefined Symbols Error
body: <p>I'm quite new to C++/CMake and was trying to create a CMake file that would compile a GRPC project. I can generate the client (only want client) files fine using this CMake, but I'm trying to create another file (<code>base.cpp</code>) that will import a class (<code>ManagerClient</code>) from one of these files. I decided to create a header file for this file I want called <code>manager_client.h</code>.</p>
  <p>I wasn't too sure where in the CMake file to compile <code>base.cpp</code> so added it as one the target directories and assumed the header file I made would get automatically linked. After running <code>make</code>, I am getting this error:</p>
  <pre><code>Undefined symbols for architecture x86_64:
    &quot;ManagerClient::ManagerClient(std::__1::shared_ptr&lt;grpc::Channel&gt;)&quot;, referenced from:
        ReadUntilClient::ReadUntilClient() in base.cpp.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[2]: *** [base] Error 1
  make[1]: *** [CMakeFiles/base.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  <p>I found this <a href="https://stackoverflow.com/questions/29293394/where-does-the-1-symbol-come-from-when-using-llvms-libc">question</a>, but didn't really explain how I could resolve my issue. The strange thing is prior to making <code>base.cpp</code>, I was able to run <code>base.cpp</code> logic inside <code>manager_client.cpp</code>'s main function without any issue, so I'm suspecting either I'm compiling it wrong via CMake or my header file is wrong. Any ideas where it's coming from?</p>
  <p>Here is the code:</p>
  <p><code>manager_client.cpp</code></p>
  <pre><code>#include &lt;grpcpp/grpcpp.h&gt;
  #include &lt;grpc/grpc.h&gt;
  #include &lt;grpcpp/channel.h&gt;
  #include &lt;grpcpp/client_context.h&gt;
  #include &lt;grpcpp/create_channel.h&gt;
  #include &lt;grpcpp/security/credentials.h&gt;
  #include &lt;string&gt;
  #include &lt;memory&gt;
  
  #include &quot;minknow_api/manager.grpc.pb.h&quot;
  
  using grpc::Channel;
  using grpc::ClientContext;
  using grpc::Status;
  using grpc::ClientReader;
  using minknow_api::manager::ManagerService;
  using minknow_api::manager::FlowCellPositionsRequest;
  using minknow_api::manager::FlowCellPositionsResponse;
  
  
  class ManagerClient {
    public:
      ManagerClient(std::shared_ptr&lt;Channel&gt; channel) : stub_(ManagerService::NewStub(channel)) {}
  
    std::unique_ptr&lt;ClientReader&lt;FlowCellPositionsResponse&gt; &gt; flow_cell_positions(FlowCellPositionsRequest request) {
        ClientContext context;
        return stub_-&gt;flow_cell_positions(&amp;context, request);
    }
    private:
      std::unique_ptr&lt;ManagerService::Stub&gt; stub_;
  };
  
  int main(int argc, char* argv[]) {
    return 0;
  }
  </code></pre>
  <p><code>manager_client.h</code></p>
  <pre><code>#pragma once
  
  #include &lt;grpcpp/grpcpp.h&gt;
  #include &lt;grpc/grpc.h&gt;
  #include &lt;grpcpp/channel.h&gt;
  #include &lt;grpcpp/client_context.h&gt;
  #include &lt;grpcpp/create_channel.h&gt;
  #include &lt;grpcpp/security/credentials.h&gt;
  #include &lt;string&gt;
  #include &lt;memory&gt;
  
  #include &quot;minknow_api/manager.grpc.pb.h&quot;
  
  using grpc::Channel;
  using grpc::ClientContext;
  using grpc::Status;
  using grpc::ClientReader;
  using minknow_api::manager::ManagerService;
  using minknow_api::manager::FlowCellPositionsRequest;
  using minknow_api::manager::FlowCellPositionsResponse;
  
  class ManagerClient {
    public:
      ManagerClient(std::shared_ptr&lt;Channel&gt; channel);
      std::unique_ptr&lt;ClientReader&lt;FlowCellPositionsResponse&gt; &gt; flow_cell_positions(FlowCellPositionsRequest request);
    private:
      std::unique_ptr&lt;ManagerService::Stub&gt; stub_;
  };
  </code></pre>
  <p><code>base.cpp</code></p>
  <pre><code>#include &lt;grpcpp/grpcpp.h&gt;
  #include &lt;grpc/grpc.h&gt;
  #include &lt;grpcpp/channel.h&gt;
  #include &lt;grpcpp/client_context.h&gt;
  #include &lt;grpcpp/create_channel.h&gt;
  #include &lt;grpcpp/security/credentials.h&gt;
  #include &lt;string&gt;
  #include &lt;thread&gt;
  #include &lt;memory&gt;
  #include &lt;iostream&gt;
  
  #include &quot;manager_client.h&quot;
  #include &quot;minknow_api/manager.grpc.pb.h&quot;
  
  using grpc::Channel;
  using grpc::ClientContext;
  using grpc::Status;
  using grpc::ClientReader;
  using minknow_api::manager::FlowCellPositionsRequest;
  using minknow_api::manager::FlowCellPositionsResponse;
  
  class ReadUntilClient {
    public:
      ManagerClient manager;
      ReadUntilClient() : manager(grpc::CreateChannel(&quot;127.0.0.1:9501&quot;,
                            grpc::InsecureChannelCredentials())) {}
  };
  
  int main(int argc, char* argv[]) {
    ReadUntilClient client;
    return 0;
  }
  </code></pre>
  <p><code>CMakeLists.txt</code></p>
  <pre><code>// Above this I compile the proto files &amp; I only included the code for relevant files
  add_library(rg_grpc_proto
    ${man_grpc_srcs}
    ${man_grpc_hdrs}
    ${man_proto_srcs}
    ${man_proto_hdrs})
  target_link_libraries(rg_grpc_proto
    ${_REFLECTION}
    ${_GRPC_GRPCPP}
    ${_PROTOBUF_LIBPROTOBUF})
  
  foreach(_target
    manager_client
    base)
    add_executable(${_target}
      &quot;${_target}.cpp&quot;)
    target_link_libraries(${_target}
      rg_grpc_proto
      ${_REFLECTION}
      ${_GRPC_GRPCPP}
      ${_PROTOBUF_LIBPROTOBUF})
  endforeach()
  </code></pre>