Search code examples
gccmakefilelinkerobject-files

How to compile a set of C files with a set of object files in C


So my question is that i have a set of C files (Lot of them), I have another set of c files which are already compiled and they are translated to type .o(object) and .d (dependency)

My Questions:

  • Now in my project I have to add the second set of object files and compile Successfully the complete stand and create a binary out of it.
  • What are the different ways of achieving this (pros and cons)

Required info: - C compilation - GNU tool chain - Hightec compiler

Please let me know if any more information is needed


Solution

  • Assuming that you no longer need to touch the source code of the second set (the set of object files) and it contains no dependency on the first one (the set of .c files), I would simply cram all its .o files into a separate library and then link to it at the end.