< Previous | Contents | Next >

Creating an Executable File

The file that you run to launch a programwhether youre talking about a game or a business applicationis an executable file. There are several steps to creating an executable file from Cþþ source code (a collection of instructions in the Cþþ language). The process is illustrated in Figure 1.1.

1. First, the programmer uses an editor to write the Cþþ source code, a file that usually has the extension .cpp. The editor is like a word

processor for programs; it allows a programmer to create, edit, and save source code.

2. After the programmer saves a source file, he or she invokes a Cþþ compileran application that reads source code and translates it into an object file. Object files usually have the extension .obj.

3. Next, a linker links the object file to any external files as necessary, and then creates the executable file, which generally ends with the extension

Introducing Cþþ 3


.exe. At this point, a user (or gamer) can run the program by launching the executable file.



image

Figure 1.1

The creation of an executable file from Cþþ source code.


Hin t

image

The process I’ve described is the simple case. Creating a complex application in Cþþ often involves multiple source code files written by a programmer (or even a team of programmers).

image


To help automate this process, its common for a programmer to use an all-in- one tool for development, called an IDE (Integrated Development Environment). An IDE typically combines an editor, a compiler, and a linker, along with other

4 Chapter 1 n Types, Variables, and Standard I/O: Lost Fortune


tools. A popular (and free) IDE for Windows is Microsofts Visual Cþþ Express Edition. You can find out more about this IDE (and download a copy) at http:// www.microsoft.com/express/.