Once we run Code::Block we will be presented with this interface. Click on "Create a new project":
This form will open up. Click on "Empty Project" and than click on "Go":
Click on "Next":
Name for our project will be "Main". You can leave default path for files, just remember where your files are:
We will set compiler to be GNU GCC, and also checkboxes "Create Debug configuration" and "Create Release configuration". Leave paths default. Click on "Finish":
Go to Menu and click on File > Empty File:

Also, confirm adding this file to Project:
File explorer will open up. Save file as main.cpp Please note, file name is lowercase main.cpp, don't forget .cpp extension.
New window will start. Check both "Debug" and "Release" options and click on "OK":
Copy-Paste this source code in main.cpp. We need to compile it into executable.
We will explain every line in future tutorials, but for now we are happy if we can get executable file.
#include <iostream>
using namespace std;
int main() {
cout << "Our custom string to print" << endl;
return 0;
}
After source is pasted, or typed, click in Menu on Build and Run to create and execute main.exe:
If you see black screen with these lines, we compiled main.cpp into main.exe just fine:
You will find main.exe in Main project folder, inside bin, inside Debug folder. We can also use DOS to run our .exe programs.
In future tutorials we will explain source code from this tutorial.
So far, so good.
You are strongly advised to check corresponding YouTube video on How to Compile C++ source into Executable.
No comments:
Post a Comment