Generally speaking, whether it is C, C++, or pas, the source file must first be compiled into an intermediate code file, which is an .obj file under Windows and an .o file, which is an Object File under UNIX. This action is called compile (compile). ). Then a large number of Object Files are synthesized into executable files, which is called a link.
When linking, mainly link functions and global variables, so we can use these intermediate object files (O files or OBJ files) to link our applications. The linker does not care about the source file where the function is located, but only the intermediate object file (Object File) of the function. Most of the time, because there are too many source files, there are too many intermediate object files generated by the compilation, and it is necessary to clearly point out the intermediate object file when linking. The object file name, which is very inconvenient for compilation, so we have to make a package (???) for the intermediate object file. Under Windows, this package is called "Library File" (Library File), which is .lib or . The dll file, under UNIX, is the Archive File, which is the .a file.
To sum up, the source file will first generate the intermediate object file, and then the intermediate object file will generate the execution file. At compile time, the compiler only checks the program syntax, and whether functions and variables are declared. If the function is not declared, the compiler will give a warning, but can generate Object File. When linking the program, the linker will look for the implementation of the function in all Object Files. If it can't find it, it will report a linker error code (Linker Error). Under VC, this kind of error is generally: Link 2001 Error, which means that the linker could not find the implementation of the function. You need to specify the Object File of the function.
Ref:
https://blog.csdn.net/liang13664759/article/details/1771246