Home  >  Article  >  Operation and Maintenance  >  What is the o file in linux

What is the o file in linux

WBOY
WBOYOriginal
2022-06-28 17:03:408253browse

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.

What is the o file in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the o file in Linux

.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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn