In Linux, the ".o" file refers to the target file, and ".o" is the abbreviation of object; the ".o" file in Linux is equivalent to the ".obj" file in Windows, and the target The file contains machine code and data used by the code when it is run, such as relocation information, program symbol tables used for linking or debugging, and other debugging information.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
.o is object, which is equivalent to the obj file compiled under windows, commonly known as the object file.
The object file (objectfile) is Computer files that store object code are often "called" binaries. The object file contains machine code (which can be executed directly by the computer's central processor) and data used by the code when running, such as relocation information, such as the program symbol table (names of variables and functions) used for linking or debugging, in addition to Includes additional debugging information.
There are three types of target file forms under Linux:
Executable target files, relocatable target files and shared target files. There are also corresponding ones called executable files, object files, and shared libraries. They just have different terms and refer to the same thing.
Executable object file: contains binary code and data and can be executed directly in memory.
Relocatable target file: Contains binary code and data that can be combined with other relocatable target files at compile time to create an executable target file.
Shared object file: It is a special relocatable object file that can be dynamically loaded into memory and linked during loading or runtime.
In fact, compilers and assemblers generate relocatable object files (including shared object files). The linker generates an executable object file.
Object file file format under Linux:
Due to the compiled intermediate files (.obj under Windows and .o under Linux), dynamic link libraries and static The link library (.lib.dll under Windows and .a.so under Linux) is similar in content and structure to the executable file, so it is generally stored in the same file format as the executable file.
Extended knowledge:
Generate .o file:
gcc -c test.o test.c
Generate .a file:
ar cqs test.a test.o
.o It is equivalent to the obj file in windows. A .c or .cpp file corresponds to a .o file
.a is a combination of several .o files, used for static connection, that is, STATIC mode, multiple. a can be linked to generate an exe executable file
.so is a shared object, used for dynamic connection, similar to Windows dll, loaded only when used
Recommended learning:Linux video tutorial
The above is the detailed content of What is the o file in linux. For more information, please follow other related articles on the PHP Chinese website!