title: Compile C file within C++ library in Makefile.am
body: <p>I am forking an existing project on Github that I want to make some changes to. One thing I want to do is add an extra file. This file should be in one of the libraries that the Makefile.am generates. The problem is that the file I want to add is a .c file, while everything else in the project is .cpp.</p>
  
  <p>The library that should contain the file is used like this in the makefile:</p>
  
  <pre><code>MYLIBRARY=path/mylibrary.a
  
  ...
  
  path_mylibrary_a_CPPFLAGS = $(AM_CPPFLAGS)
  path_mylibrary_a_CXXFLAGS = $(AM_CXXFLAGS)
  path_mylibrary_a_SOURCES = \
    path/cppfile1.cpp \
    path/cppfile1.h \
    path/cppfile2.cpp \
    path/cppfile2.h \
    path/cppfile3.cpp \
    path/cppfile3.h
  
  ...
  
  mybinary_LDADD = $(MYLIBRARY)
  </code></pre>
  
  <p>Simply adding the <code>path/cfile.c</code> and <code>path/cfile.h</code> to the list of sources gives me the following error:</p>
  
  <pre><code>CXXLD    mybinary
  /usr/bin/ld: path/mylibrary.a(path_mylibrary_a-cfile.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
  path/mylibrary.a: error adding symbols: Bad value
  </code></pre>
  
  <p>What can I do so the Makefile.am will compile the c file in a project that otherwise is built in c++?</p>