Compile Cpp file to Exe

This tutorial will give you a step-by-step guide for converting C++ source files into .exe files, runnable on most (to avoid the word “all”) Windows computers.  This guide assumes that the C++ source code is for a console application and does not require any outside libraries.

STEP 1: First you need to get a C++ compiler. One of the best for Windows machines is the free Microsoft Visual C++ 2012 Express.

:1

STEP 2:Start a new project in Visual C++. This is pretty simple. Click the “New Project” button in the top left, then follow the steps to make an “Empty Project”. Then name it, and on the next pop-up hit “Finish”.

2

STEP 3: Copy and paste all of the .cpp files into the “Source Files” directory, and copy-paste all the .h files (if there are any) into the “Header Files” directory. Rename the main .cpp file (the one that contains “int main()” in it) to the name of the project that you chose. The external dependencies file will fill itself.

STEP 4:Build and compile. Press the [F7] key after you have finished all of the above and the program will be created.

STEP 5: Find the exe file. Navigate to the “Projects” file that Visual C++ installs all of the programs to (in Windows 7, it will be in your Documents). It will be in the file with the name you gave it earlier, under the “Debug” directory.

3

STEP 6: Test it. Double-click on the .exe file to run it, and if everything went well, the program should work fine. If it doesn’t, try going through the steps again.

4

Advertisements