Skip to content
Snippets Groups Projects
Commit b876a179 authored by antux18's avatar antux18
Browse files

Suppr T4 doublon + correction T4.

parent 86429f2d
No related merge requests found
Compiling translates C code into object code without including the code of functions and variables from external libraries (such as stdio or stdlib) and files.
Linking will take all the previously created object code files and combine them together, along with the code of functions and variables from external libraries, resulting in a working executable file.
\ No newline at end of file
......@@ -2,16 +2,10 @@ Output report:
In all three cases the program takes an input array that is: 5 9 1 2 3
In cases 1 and 3 the array is sorted in the ascending order with an output being: 1 2 3 5 9
Whereas in case 2 the array is sorted in the descending order with an output being: 9 5 3 2 1
That is due to the fact that L1, L2 and L3 are not compiled with the same libraries.
That is due to the fact L1, L2 and L3 are not compiled with the same libraries.
When compiling L1 and L2 the -c option says not to run the linker to just produce object files as output from the C files l1.c and l2.c which are then linked to the object file created by compiling T3.c in the second gcc command.
In L1 and L2 the produced object files are linked to two different libraries which causes the array to be sorted in different orders.
In L3 there is no linking, all the c files, including the one that was used to create the library libmylib1.a are given to the compiler which produces an executable. So the same sorting function is applied at the end in L1 and L3 even though the compilation process isn't exactly the same (with and without creating and linking a library) that's why their outputs are identical.
The library mylib1 from l1.c sorts in the ascending order and mylib2 from l2.c sorts in the descending order.
When compiling L1 and L2 the -c option says not to run the linker to just produce object files as output from the C files l1.c and l2.c which are then linked to the object file created by compiling T3.c in the second gcc command.
In L1 and L2 the produced object files are linked to two different libraries which causes the array to be sorted in different orders. In fact, the library mylib1 from l1.c sorts in the ascending order and mylib2 from l2.c sorts in the descending order.
In L3 there is no linking. All the C files, including the one that was used to create the library libmylib1.a are given to the compiler which produces an executable. So the same sorting function is applied at the end in L1 and L3 even though the compilation process isn't exactly the same (with and without creating and linking a library) that's why their outputs are identical.
Starting libraries name with "lib" is a naming convention, this part of the name can then be dropped at the linking phase indicated when specifing the folder in which to look in for the library with -L and the library's name with -l<library name>.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment