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.
The library that should contain the file is used like this in the makefile:
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)
Simply adding the path/cfile.c
and path/cfile.h
to the list of sources gives me the following error:
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
What can I do so the Makefile.am will compile the c file in a project that otherwise is built in c++?
path_mylibrary_a_CFLAGS
variable? Suitably initialized of course. – Some programmer dude