Наши партнеры








Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

Linux Compilers and Assemblers

SEP 19, 2003 By Christopher Paul, Rafeeq Rehman. Article is provided courtesy of Prentice Hall.

3.4 Linking a program

As mentioned earlier, building an executable binary file from a source code file is a multi-stage process.

The gcc compiler usually carries all these steps for you by default. However you can stop gcc at any of these stages for various reasons. You have already seen how to create assembler code from a C source code file. In most software projects, output binaries are built from many source code files. For this purpose you have to compile these source code files to object files one by one before you can generate the output binary file. After creating these object files, you can link these files using gcc to the final executable.

The gcc compiler gets help from different programs during the four steps listed earlier in this chapter. During the linking part, the ld program is invoked with appropriate arguments to link one or many object files together with libraries to generate an executable. Command line switches used with ld can be found using manual pages.

The linker is a part of GNU binary utilities package also known as binutils. You can download and install the latest version of GNU linker if you need to do so.


Next Section 5. Assembling a Program
© 2003 Pearson Education, Inc. InformIT Division. All rights reserved.
800 East 96th Street Indianapolis, Indiana 46240