The object files that define those symbols are extracted from the archive and included in the final executable.
http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/test.ctest.c
int f ()
{
return 3;
}
http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/app.capp.c
int main ()
{
return f ();
}
The following command line will not work:
$ gcc -o app -L. -ltest app.o
app.o: In function 'main':
app.o(.text+0x4): undefined reference to 'f'
collect2: ld returned 1 exit status
On the other hand, if we use this line, no error messages are issued:
$ gcc -o app app.o -L. -ltest
The reason is that the reference to f in app.o causes the linker to include the test.o object file from the libtest.a archive.