Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the relationship between LIS, OBJ and EXE files?

Tags:

c

openvms

I am working with a different compiler CC. It doesn't work like GCC.

When I was using GCC, I can do "gcc -o exe_filename source_filename" and the output would be a exe file.

When I use CC, I need 2 steps. First I compile the source files (suppose it involve a .c and a .h file ) and it create a .lis file and a .obj file. Then I do a link command which created a .exe file.

What is the relationship between LIS, OBJ and EXE files? I ask this because I wonder which files do I need if I want to use the exe in another machine without including unnecessary files. If LIS and OBJ were only used for compilation, I don't need it in another machine.

like image 897
lamwaiman1988 Avatar asked Dec 04 '25 17:12

lamwaiman1988


2 Answers

The compiler takes C files (and includes H files as referenced) and produces object (OBJ) and listing (LIS) files. The object file contains the code and data, but has unresolved external references. The listing typically includes line numbers, error and warning messages, and optional sections such as a type and variable cross-reference.

The linker combines object files and resolves external references to libraries. The result is an executable (EXE) image. (Or shareable image when creating libraries.)

Only the executable file needs to be copied from one system to another to run the application. The listing may be useful for interpreting error messages as it provides the properly correlated line numbers. The object could be useful if the application needs to be relinked due to changes in libraries, particularly if the target system has older versions than the original system.

like image 192
HABO Avatar answered Dec 06 '25 08:12

HABO


the OBJ files are the compiled C files in a format that they can be "Linked" together by a linker and turned into an EXE.

Compile -> OBJ -> Link -> EXE

the LIS file is just informational output of the C that the compiler ends up compiling.

All you need once compiled and linked is the EXE

like image 22
Keith Nicholas Avatar answered Dec 06 '25 08:12

Keith Nicholas