GitLab now enforces expiry dates on tokens that originally had no set expiration date. Those tokens were given an expiration date of one year later. Please review your personal access tokens, project access tokens, and group access tokens to ensure you are aware of upcoming expirations. Administrators of GitLab can find more information on how to identify and mitigate interruption in our documentation.
There was an error fetching the commit references. Please try again later.
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.
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>.