title: Linking C from C++ in OS X Mavericks
body: <p>Having transitioned to OS X Mavericks and XCode 5.0.1, I can no longer gracefully link compiled C files (output from gcc) to a C++ project (output from g++).</p>
  
  <p>The offending pair of commands produced from my makefile are:</p>
  
  <pre><code>gcc `pkg-config --cflags glib-2.0` -g -Wall -O3 `pkg-config --cflags flann`   -c -o vec.o vec.c
  g++ `pkg-config --cflags glib-2.0` -g -Wall -O3   -stdlib=libstdc++ -lstdc++  layoutquality.cpp vec.o  `pkg-config --libs glib-2.0`  -L/usr/local/Cellar/flann/1.8.4/lib -lflann -o layoutquality
  </code></pre>
  
  <p>To which the linker complains:</p>
  
  <blockquote>
    <p>Undefined symbols for architecture x86_64:
     "load_dmat(char const*)", referenced from:
         _main in layoutquality-I8HOqy.o
    ld: symbol(s) not found for architecture x86_64</p>
  </blockquote>
  
  <p>Where <code>load_dmat</code> is just a function in the file vec.c .  If I replace the <code>gcc</code> with <code>g++</code> in the first line, then everything compiles and links fine, but clang says:</p>
  
  <blockquote>
    <p>clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated</p>
  </blockquote>
  
  <p>Is there an inoffensive, non-deprecated way of compiling and linking these?  Linking with <code>g++</code> together with object files from <code>gcc</code> worked fine before I upgraded to OS X Mavericks and the new command line tools.  Any insight into what changed and how to go forward would be great, thanks.</p>