Welcome back. You have already created, built, and run a C++ console project in Visual Studio. You saw a source file in the editor, a successful message in the Output window, and Hello World! in a console window. Those are related, but they are not the same thing.
This lesson looks behind the Build menu. By the end, you should be able to distinguish the program text you write, the intermediate files created during building, and the final Windows program that actually runs.
One program, several forms
Consider the starter file in your project, perhaps named FirstConsole.cpp. Its contents are source code: human-readable instructions written in C++.
A simplified version looks like this:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
You can read and edit this text in Visual Studio. Windows cannot run this .cpp file directly, however. A processor needs machine instructions, stored in a binary format rather than C++ text.
When you select Build > Build Solution, Visual Studio uses the Microsoft C++ toolchain installed with the C++ workload. The toolchain transforms your source code into files Windows can use.

The important distinction is:
| Item | Typical extension | What it is | Can you edit it as C++? | Can Windows run it directly? |
|---|---|---|---|---|
| Source code | .cpp | The C++ instructions you write | Yes | No |
| Object file | .obj | Compiled machine-code pieces | No; it is binary data | Not normally |
| Executable | .exe | The completed Windows application | No; it is binary data | Yes |
A useful rule is: you edit source code; the build tools create outputs; Windows runs the executable.
What “build” actually does
“Build” is the umbrella name for turning a project’s source code into a runnable program. Visual Studio hides most of the mechanical detail behind one menu command, but understanding the broad stages will make build messages much less mysterious.
C/C++ projects and build systems in Visual Studio
Read the official Microsoft overview to connect Visual Studio’s Build command with the underlying C++ tools. It establishes the exact roles of preprocessing, compilation, object files, and linking.
In the C++ compilation section, read the three build stages. Focus on the different output of compilation and linking; do not worry about every tool option or the command-line discussion that follows.
For a simple Visual Studio project, think of a build as three main jobs:
-
Preprocessing handles instructions beginning with
#, such as the#include <iostream>near the top of the starter program. This prepares the C++ text for compilation. Visual Studio normally performs this silently. -
Compilation checks the prepared C++ code against the language rules and translates each C++ source file into an object file. On Windows, object files usually end in
.obj. -
Linking combines the object file or files with the required library code and produces the final executable, which ends in
.exeon Windows.
A project with only one .cpp file can still involve all these stages. Larger programs commonly contain several .cpp files. Each is compiled separately into its own .obj file, then the linker brings the pieces together into one application.
The precise internal steps can be more detailed than this, but this three-part view is the one to retain now: prepare, compile, link.
The compiler does not directly make “a running program”
The phrase “compile the program” is often used informally to mean the entire build. More precisely, the C++ compiler’s main output is an object file; the linker creates the final executable.
An object file contains machine-level code, but it is incomplete on its own. For example, your source code uses std::cout to display text. The compiler translates your use of that feature, but the linker also has to connect your program with the appropriate library support.
That is why an .obj file is not normally what you double-click or run. It is one component of the final program.
By contrast, an executable is packaged in the form Windows expects to launch. When you use Ctrl+F5, Visual Studio starts the project’s .exe file. The console window is the result of that executable running.
Do not confuse these two kinds of “output”:
- The Output window in Visual Studio shows a textual build log: messages from the compiler, linker, and build system.
- Build output files are the files created on disk, such as
.objand.exe.
The first kind tells you what happened; the second kind is what the tools produced.
Follow your project’s artifacts in Visual Studio
Build your existing FirstConsole project again with Build > Build Solution. In the Output window, look for lines that identify files being processed and a final success summary, such as:
Build: 1 succeeded, 0 failed
Depending on your Visual Studio version and settings, you may also see a line containing the path of the final .exe file. That line is especially useful: it tells you where Visual Studio placed the executable.
Build locations depend on your active configuration and platform. A common location resembles one of these:
FirstConsole\x64\Debug\FirstConsole.exe
FirstConsole\Debug\FirstConsole.exe
The exact folder is not important. The important pattern is that Visual Studio keeps generated files in a configuration-specific output folder, rather than mixing them with the .cpp source file at the project’s top level.
A short observation activity
Use the Output window rather than guessing the folder:
- Save your project with Ctrl+S.
- Build the solution.
- Find the successful build summary and, if shown, the executable path.
- Open the project folder in File Explorer and locate the configuration folder named something like
Debugorx64\Debug. - Look for a file whose type is Application and whose name ends in
.exe.
You may also find .obj, .pdb, .ilk, or other generated files. For this lesson, you only need to identify the .exe as the runnable program and .obj as a compiled intermediate file. Leave the other files alone; Visual Studio manages them for you.
A change is not active until you build again
Suppose you change the text in your .cpp source file and save it. You have changed the source code, but the old executable still exists on disk. It still contains the instructions from the previous successful build.
Only after a successful build does Visual Studio create an updated executable from your changed source.
This explains a common beginner surprise:
“I edited the code, but the program still behaved as before.”
Usually, either the file was not saved, the project was not rebuilt, or a different project/executable was run. Your normal routine prevents all three:
- Edit the
.cppsource file. - Save it.
- Build and inspect the result.
- Run the executable with Ctrl+F5.
- Check whether the console behavior matches the new source.
A successful build establishes that the tools could transform your source code into an executable. It does not prove that your program’s logic is correct. A program can build perfectly and still display the wrong answer because its instructions are wrong. You will learn to diagnose both kinds of problem over the course.
Keep the vocabulary precise
Here is the full chain for your current project:
| Term | Meaning in your FirstConsole project |
|---|---|
| Source code | The editable C++ text in FirstConsole.cpp. |
| Compiler | A tool that checks and translates C++ source into machine-code components. |
| Object file | A generated .obj component, usually one for each compiled .cpp file. |
| Linker | A tool that combines object files and needed library code. |
| Executable | The generated .exe Windows can launch. |
| Build | The overall operation that runs the necessary tools to produce the executable. |
| Build log | Text in Visual Studio’s Output window describing the build’s progress and result. |
You do not need to manually run the compiler or linker in this course. Visual Studio coordinates them. Still, knowing that they are separate tools gives meaning to messages like compiler error, linker error, and Build succeeded.
Key takeaways
- A
.cppfile is source code: readable C++ text that you edit. - Building transforms source code into machine-readable files.
- Compilation produces intermediate
.objobject files; linking produces the final.exeexecutable. - The Output window is a report about the build, while
.objand.exefiles are actual build products. - Saving changes does not update the executable; a successful build does.
- Ctrl+F5 runs the executable created by the most recent successful build.
Next, you will begin writing C++ deliberately by examining the program’s entry point: the main function, its braces, and the sequential statements inside it.
Can't find a good explanation? Sign up and we'll make it for you
Sign up