diff --git a/ex1/Exercise_1_T4 b/ex1/Exercise_1_T4 new file mode 100644 index 0000000000000000000000000000000000000000..d6fa670666f5e2f8927b5011e82bfbebd7381183 --- /dev/null +++ b/ex1/Exercise_1_T4 @@ -0,0 +1,3 @@ +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 diff --git a/ex1/Exercise_1_Task_3 b/ex1/Exercise_1_Task_3 index 34c89e8b6e6390487c8c08a06a9eff489896a8fd..764d19b4c8afd95da136cff8b96eab6a1bd0b5a7 100644 --- a/ex1/Exercise_1_Task_3 +++ b/ex1/Exercise_1_Task_3 @@ -1,7 +1,17 @@ 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 ascendant order with an output being 1 2 3 5 9. +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 -When compiling L1 the -c option says not to run the linker to get object files as output. -Assembling and Linking +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. + + + +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>.