Home > Article > Backend Development > Can functions in C language be compiled separately?
#Can functions in c language be compiled separately?
OK.
Recommended tutorial: "c Language Tutorial"
For example, library function is to put the function in the library, compile some commonly used functions and put them in a file , for different people to call. The library functions of C language are not part of the C language itself. It is a set of programs compiled by the compiler according to the needs of general users and provided for users to use.
Static compilation in windows places both the export declaration and implementation in lib. The dynamic LIB file is equivalent to an h file in C language. It is a declaration of the function export part, without embedding the implementation process into the program itself. After compilation, it only stores the function address in the host program. When running to call the function, it calls the DLL and Load the function to implement the specific operation of the function.
Therefore, functions in C language can be compiled and exported separately.
Extended information:
Related methods and files for separate compilation:
1. The lib file must be connected during compilation in the application, and the dll file is called during runtime. If there is a dll file, the corresponding lib file is generally some index information, and the specific implementation is in the dll file. If there is only a lib file, then this lib file is statically compiled, and the index and implementation are in it.
2. There are advantages to statically compiled lib files: there is no need to install dynamic libraries when installing them to users. But there are also disadvantages, which is that the application is relatively large and the flexibility of the dynamic library is lost. When the version is upgraded, a new application must be released at the same time.
The above is the detailed content of Can functions in C language be compiled separately?. For more information, please follow other related articles on the PHP Chinese website!