vendredi 25 décembre 2020

How the linker find the correct library?

I know what preprocessing is, how compiler works, and how linker links the object files

But what I still haven't been able to answer is :

In an IDE like VS

suppose we have a library called DariushTest.o that implemented a function called print() and have a header file called test.h and we have other libraries that implemented the print() function but we don't include their header files in our code suppose we include the test.h header in our code and we use the print() function in our main function

NOW! if there are several libraries that have implemented this function.

after compiling the code, how does the linker find out which library this code is related to and with which file should it link?

The reason that I ask this question is that the header file doesn't connect to DariushTest.o file and the compiler doesn't care about it.

So how linker links the print() function from DariushTest.o not from other libraries? How the linker find the correct library?

Aucun commentaire:

Enregistrer un commentaire