build - How do I get make to figure out the correct dependencies to link in the correct downstream object files? -
I'm going to use a short example for reference. Consider a project with it:
inner_definitions.o: inner_definitions.cpp inner_definitions.h gcc $ ^ -o $ @ inner_clash_1.o: inner_class_1.cpp inner_class_1.hinter_diffinase Gcc $ ^ -o $ @inter_clos_2.o: inner_clos_2 CPP inner_class_HIInterial_Effinations. Gcc $ ^ -o $ @bauer_claus.o: external_clash cpt external_clash h innerial_clashir inner_closal_h gcc $ ^ -o $ @executable.o: executable. CPP executable Outer_class.h gcc $ ^ -o $ @ Executable: __? 1__ __? 2__
but filling the empty space __? Linker dependencies for <__
and __? 2 __
is not easy for the linker command.
In this small example, someone can argue that it is easy to see that __? 1__ = Inner_definitions.o Internal_clash_1.o inner_class_2.o outer_class.o executable.o
. However, this is not clearly a scalable solution because it forces every developer to understand all the dependencies of that code from which they are working so that they can be used by by Understand the dependencies
Utility
For each other solution, there will be a separate variable for each object file that lists all its downstream dependencies: i.e. __? 1__ = Executable. $ $ (Executable dependency)
. This is not a desired solution because it forces the makefile to be compiled in a specific way so that the variable can only be used when it is fully defined. Also, for larger applications, these variables may exceed the maximum variable length.
Then there is another solution to the collection. In this situation, we could construct a inner_class_1.a
, which contained both inner_defintions.o
and inner_class_1.o
, so it Anyone can be linked to this requirement for the object file requirement inner_class_1.o
without reinforcing the developers, this approach looks promising, but there are several duplicate files in it, It does not appear that the GCC
link nested collection Can handle files.
Is there any other way? What is the best way? Can GCC
linker handle nested archive files?
The job that you are doing automatically (the right object files to satisfy all the references Typically, the linker is usually left to use, using static libraries (".a" files) to group the candidate object files, as you would suggest.
An important explanation that you can remember: If you pass an archive to the Linker, then it will be linked to the files that are actually required from those files, then you do not necessarily straddle all your executables. Without a granularity, you can create archives at a very high level - the linker will pick that thing which is needed - although if you take this approach a long way, it is easy to slow down Can be made at speed.
Objects from GNU Linker Nested Libraries will not be removed. If you want to create a large library by combining many small people, you can do this in one of the "addlib" commands. This will give you a collection containing all the object files without any nested library structure.
If o Files containing the same object code related to duplication of O files and .a files bother you.
Comments
Post a Comment