title: How do you link a C++ static library to a C program?
body: <p>I have the following c++ program: </p>
  
  <p>Client.h</p>
  
  <pre><code>#ifndef Client_Client_h
  #define Client_Client_h
  
  #include "Client.h"
  
  class Client {
  
  public:
      void f1();
      void f2();
  };
  
  #endif
  </code></pre>
  
  <p>Client.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  using namespace std;
  
  #include "Client.h"
  
  void Client::f1(){
      cout &lt;&lt; "Client.f1()" &lt;&lt; endl;
  }
  
  void Client::f2() {
      cout &lt;&lt; "Client.f2()" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>compiling the above in XCode 4.3 gives me a static library file called:</p>
  
  <pre><code>libClient.a
  </code></pre>
  
  <p>Separately, I have a main.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  //
  //using namespace std;
  
  int main(){
          // how do I do something like: Client c; c.f1(); c.f2(); 
          // and actually get output ? 
          printf("hello\n");
          return 0;
  }
  </code></pre>
  
  <p>What's steps do I need to take in order to invoke f1() and f2() ? How do I use GCC to link the static library properly? </p>
  
  <p>So far I have tried: </p>
  
  <pre><code>gcc -lClient.a main.c 
  </code></pre>
  
  <p>which gives me : </p>
  
  <pre><code>ld: library not found for -lClient.a
  collect2: ld returned 1 exit status
  </code></pre>