when we want to add a library, does we add it to compiler or linker. somebody says that we add .h file and .cpp file to compiler and .dll or .exe file to linker.
can you explain me that?
If you want to call functions in a library, you need the .h file for that library so the compiler knows what routines are available and how to call them. The .h file will also contain any structure declarations that you may need.
There are two types of library objects. static and dynamic. You specify the library object to the linker so that the linker can resolve any references between your code and the library object file. A static library gets included in your object file, while a dynamic library (DLL) remains a separate file.
Whether or not you need to compile the .cpp file depends on whether you're provided a precompiled library object for your platform.
You don't normally reference a .exe file as input to the linker.