I have created a http library which contains 2 object files (web.o & webssl.o). These two files share some common constants and functions, that must be repeated for each file. Which also means that I need to update both files when changes are made.
I would like to have a webcommon.o file that I can link to the web.o and webssl.o files. It will contain all the common code that both libraries shares.
I created the webcommon.o file with the shared code. I removed the shared code from web.c and webssl.c. When I go to compile web.c and webssl.c with this:
# gcc -Wall -Werror -O3 -c web.c /my/lib/webcommon.o;
gcc: warning: /my/lib/webcommon.o: linker input file unused because linking not done
Through searching, it appears that the -c option ignores the linking of object files.
How do I create a webcommon.o object file that is used with web.o and webssl.o? Right now it looks like my only 2 options are:
Keep the duplicate code in the web.o and webssl.o and update both files when needed.
Make sure I add the webcommon.o file when compiling a program a program with either web.o or webssl.o