I'm working on a quite large and messy project that I haven't really got time to clean up and I've been tasked with providing an API for it. What I'm trying to do is wrapping all the ugly stuff up in a single static library and then provide it with a single header file.
But when trying to build an executable using the header file and library I get a bunch of "undefined reference" errors. I guess it would work if I provided all the header files, but I really don't want to have to do this.
Right now the makefile
looks something (slightly altered for simplicity) like this:
myprog.elf : libgiant_lib.a main.o
gcc -pg -o $@ main.o -lgiant_lib
main.o : main.c
gcc -c $(CFLAGS) $(SOME_INCLUDES) $< -o $@
libgiant_lib.a : $(A_BUNCH_OF_LIBS) $(COUPLE_OF_OBJS) api.o
ar rcs $@ $^
api.o : api.c api.h
gcc -c $(CFLAGS) $(INCLUDES_FOR_BUNCH_OF_LIBS) $< -o $@
I've checked the libgiant_lib.a
archive and it seems to contain all the libraries and object files it should. But still, linking against it doesn't work.
I'm pretty sure I'm missing something obvious here...