title: How to combine a C++ object file in a C project compiled with gcc (not g++)?
body: <p>Yet another C/C++ integration question: I am trying to update some legacy C library (let's call it <code>libcl.a</code>) with functionality that I have in a C++ library (let's call it <code>libcppl.a</code>). The <code>liblc.a</code> library is being used all over in my environment and is linked into many C projects, using GCC (in the C compiler mode):</p>
  
  <pre><code>&gt;&gt; gcc prog.c -lcl
  </code></pre>
  
  <p>The <code>libcl.a</code> currently consists of the <code>cl.o</code> object file (created with <code>gcc</code> from <code>cl.c</code>+<code>cl.h</code>).</p>
  
  <p>The <code>libcppl.a</code> consists of the <code>cppl.o</code> object file (created with <code>g++</code> from <code>cppl.cpp</code>+<code>cppl.h</code>).</p>
  
  <p>Because the existing applications are written in C, and the build scripts are using GCC, I'd like to keep the transition to the updated library as simple as possible. Thus, I want to keep using GCC as the main compiler but still be able to link with the updated library.</p>
  
  <p>Finding <a href="https://stackoverflow.com/a/1001576/274579">this answer</a>, I could link C++ objects into GCC C project using <code>-lstdc++</code>:</p>
  
  <pre><code>&gt;&gt; gcc -c cl.c   -o cl.o
  &gt;&gt; g++ -c cppl.c -o cppl.o
  &gt;&gt; ar rcs libcl.a cl.o cppl.o
  &gt;&gt; gcc prog.c -lcl -lstdc++
  </code></pre>
  
  <p>However, I want to <strong>eliminate the explicit mention of the</strong> <code>libstdc++</code> <strong>in the compile command line</strong>.</p>
  
  <p>What I tried to do was to include libstdc++ in the cl library, by doing:</p>
  
  <pre><code>&gt;&gt; ar rcs libcl.a cl.o cppl.o /usr/lib/libstdc++.so.6
  </code></pre>
  
  <p>However, when building the application, I get:</p>
  
  <pre><code>&gt;&gt; gcc prog.c -lcl
  In file included from cppl.cpp:2:
  ./libcl.a(cppl.o):(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p><strong>1. Why doesn't the gcc linker find the C++ standard library that was archived together with my objects?</strong></p>
  
  <p><strong>2. Is there a limitation on using</strong> <code>ar</code> <strong>with libraries (as opposed to object files)?</strong></p>
  
  <p><strong>3. Is there a way to overcome this problem?</strong></p>