title: Linking C++ to C in GCC
body: <p>I have one function <code>extern "C" int ping(void)</code> in a C++ "static-library" project. Now, I would like to write a simple Hello-World <code>C</code> program that will call this function <code>int x = ping();</code>.</p>
  
  <p>I use <code>g++ / gcc</code> but I cannot link the <code>C</code> executable with <code>C++</code> shared library. Please, how can one do that? Could you please provide exact <code>gcc</code> commands?</p>
  
  <p><strong>Edit</strong>:</p>
  
  <pre><code>g++ -c -static liba.cpp
  ar rcs liba.a liba.o
  gcc -o x main.o -L. -la
  </code></pre>
  
  <p>and get:</p>
  
  <pre><code>./liba.a(liba.o):(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
  </code></pre>
  
  <p>collect2: ld returned 1 exit status</p>