How To Build A C++ Program

The C++ programming language is generally familiar to most programmers. Generally, the greatest concentration of hardcore C++ programmers tends to be among those with a background in computer science and similar fields. However, C++ is not an elitist language – it’s one of the most popular programming languages worldwide and often features among the top two or three computer languages on any list. Perhaps you too want to start programming in C++, or you want to improve your knowledge of modern methods of C++, but don’t know where to start? In this post, we explain simply how you can download a free C++ Code Editor and compiler and how you can build C++ program as a first step on Windows, iOS, Android and Linux.

How to download a code editor to build a C++ program?

How To Build A C++ Program the C++ logo

C++ is a powerful programming language with many features that enable you to write almost any app you could ever want. Using a fast and reliable C++ Compiler and IDE is very important for beginners and professionals to develop C++ apps for Windows and other operating systems. When a user wants to develop modern C++ applications, they should learn to use a professional IDE.

C++ Builder CE is the easiest and fastest C & C++ IDE for developing simple or professional applications on different operating systems. It is also straight-forward for beginners to learn with its wide range of samples, tutorials, help files and LSP support. C++ Builder comes with Rapid Application Development Studio, also known as RAD Studio.

You can download the free C++ Builder Community Edition here: https://www.embarcadero.com/products/cbuilder/starter.

Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://www.embarcadero.com/products/cbuilder.

How to use a code editor to build a C++ program?

C++ Builder IDE has mainly 5 Parts, the Code Editor Window and Form Designer, Projects Window, Palette Window, Structure Window, Object Inspector Window. You can find the less commonly used windows from the main IDE menu as well as the right-click context menus. All the basic sections can be summarized in this IDE picture:

How To Build A C++ Program the RAD Studio IDE

How to build a C++ console application program in C++ builder

If you download C++ Builder Community Edition (or the RAD Studio CE version) or any Professional, Architect, Enterprise versions of C++ Builder, or Dev-C++, VC++, GNU C/C++ then we can start to code, you can follow these steps to run your program,

  1. Create a new Project (a console application, a solution)
  2. Start coding with very simple code and save all project files including cpp files.
  3. Press the Run Button or Keys of IDE or use a compiler to compile your codes.

As an example, now, let’s do these steps in C++ Builder.

  1. Use menu File ->New->”Console Application – C++ Builder” to create a new C++ console application. In the next window, press OK to write your codes.

When you start coding, first of all, you should include libraries that you wish to use. The C++ language has many libraries and each of them has commands or functions for specific tasks. For example, the iostream library has standard input and output methods to display data and read from files and similar sources. Generally, for beginners, the iostream header is enough to enable you to create simple apps. We can include this library header as below,

Second, you should add a main procedure. This is the main part of the program – hence the name – and it is executed first. In the simplest sense, all other parts of your program are launched from the main section either directly or indirectly. Things get a little more complicated than that once you start to write more complex programs but for now you can think of the main section as the ‘main loop’ where things begin to happen in your program code.

After that you should write your lines of program code into this procedure, between the { and } brackets. If you are a beginner, “Hello World” examples are good to understand how the basic feature of a particular programming language works. It is also a good way to understand how to edit text, how the syntax (the rules) of the language work, how to compile and link, how to debug and execute, and how to deploy or release. This full example below is a “Hello World” C++ example that can be run with C++ Builder too.

Here is Hello World C++ example as a console application,

In C and C++, after every command you use you should put a semicolon “;”. In this example above we print a text with std::cout method and then we wait to get a character input (key press) with getchar(); functions, then we exit and return 0; which means our main app has run successfully and exits.

In this example above we define main() function as a integer (int) function, that means we should return a integer value. Here, we print a text with printf() function and then we wait to get a character input (key press) with getchar(); function, sometimes this is necessary to see results when running it. Then we exit and return 0; which means our main app successfully ran and exited.

You can write these C++ codes above into Dev-C++ code editor or you can copy and paste it. If you are a beginner, we highly recommend you write code. This will help you to understand how C++ works and you can see your first mistakes when you are coding.

2. Coding is done now so you can save all your project files to a folder. Use File->Save Project As to save all your files.

3. After this step, you can compile and run by pressing F9, or you can run your code by pressing F10, or you can use Compile and Run buttons editor. This will print out the “Hello LearnCPlusPlus”. C++ compilers support C language too

How To Build A C++ Program the run buttons in the IDE

In C++ Builder you can simply press Run Button (without debugging or with debugging) or F9 key to compile and run your code, or you can use Run Menu to compile and run too.

How to build a modern C++ program with a GUI?

The C++ Builder CE version is free C and C++ IDE for building simple or professional applications on the Windows, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. C++ Builder comes with Rapid Application Development Studio, also known as RAD Studio, and C++ Builder is one of the most professional IDEs that work under RAD Studio. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey FMX framework for cross-platform UIs. There is a free C++ Builder Community Edition for students, beginners, and startups.

You can download the free C++ Builder Community Edition here: https://www.embarcadero.com/products/cbuilder/starter.
Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://www.embarcadero.com/products/cbuilder.

How To Build A C++ Program selecting multi device application from the menu

If you download the C++ Builder Community Edition (or RAD Studio CE version) or a free trial of the full version of C++ Builder. Install it on your windows computer and run RAD Studio or C++ Builder. Beginners and students normally start to learn C++ with simple code. Let’s create a new Multi-Device (Cross-Platform) C++ application by using FireMonkey (FMX) framework. It’s a simple program, but when we’ve finished it’s capable of running on other devices, not just a Windows PC!

Choose File->New-> “Multi-Device Application – C++ Builder” menu.

This will create a New C++ Project for Windows and can be easily compiled for other operating systems like iOS, Android. This will allow you develop C++ apps with FMX UI elements. If you don’t need UI elements, you don’t need VCL or FMX frameworks. Modern applications have a GUI’s and skinned Styles. Note that VCL projects are Windows only. FireMonkey FMX projects are Multi Device (multi-platform) applications that you can compile and run on Windows, MacOS, iOS and Android.

Save all Unit files and Project file to a folder.

How to build a modern C++ program design with GUIs?

Simply drag and drop components from the Palette window on the right side; Memo (TMemo) and Button (TButton) to your form design. Arrange their width, height and position. You can edit each of their properties from the Object Inspector on the left side.

How To Build A C++ Program the C++ IDE showing a form with a button on it

How to build a modern C++ program GUI event?

As given above, if you added the Memo and Button this means you have two Components (GUI objects) on your form, these are Memo1 GUI object from the TMemo class, and Button1 GUI object from the TButton class. If you want, you can rename them, let’s continue with these objects’ names.

If you want to create an event when user clicks on a GUI object, you must use OnClick Event of that GUI object. The most used action of Button is OnClick event, it is being auto created by using double click on it. Or you can select your button and, go to Events Section of Object Inspector,

This will forward you to code editor of C++ Builder. If you want to show a message when user clicks a button. Double click to Button to create OnClick event with a procedure, this will forward you to code editor of C++ Builder. It will create the Button1Click event automatically as below,

add the missing lines inside as below.

How to build a modern C++ program to output to a GUI?

In our example, let’s add a message to Memo1 component when the user clicks to Button1. In your FMX application development, when you are is Design Mode, Double click on Button1 to create Button1Click() event for this button. This will forward you to Code Editor. Add these lines into Button1Click() event,

This line will add “Hello, you click Button1” text to the Lines of Memo1 component. Here is the full example,

Note that you can switch between the GUI Design mode to Code Mode by pressing F12, or vice versa. If you want, you can switch to your header file (.h) of your cpp file (.cpp) from the button tabs. You can change your Build Configuration from the left Project window by setting it to Debug or Release mode.

You can run your application by pressing F9 or Run buttons.

How to build a C++ program in Linux with the gcc compiler?

On Linux, GNU C/C++ comes as the default programming language already installed. If you are using WSL on Windows, then you can use the following command in the WSL terminal to install GCC:

Generally, the gcc compiler is used as a C compiler and g++ compiler is used as a C++ compiler. If your c program file is myapp.c you can compile this with the gcc command as below,

Be sure that you have permission to write to folder there. Now you can easily run your myapp.out as given below,

How to build and run a C++ program in Linux terminal?

f you are using an actual Linux machine rather than a Windows machine, then you can use any text editor to create C++ files. Sublime Text Editor is a light editor for beginners. If you want only to edit in console Vim editor is good. Eclipse CDT is a modern C++ editor for Linux. Spyder is a good editor for Python and C++. There are other C++ editors which can be used in different Linux distributions. Some of these are, VS Code for Linux, and CodeBlocks for Linux. Let’s write our C++ code as below,

Here is the full input and output process in Linux terminal

Note that, you can compile C++ and C files with g++. If you want to compile C language projects you can use gcc C compiler too, but you cannot compile C++ files with the gcc compiler.

Although the free C++ Builder Community Edition is extremely powerful it is intended for students, beginners, and startups. If you are a regular business or do not qualify for the free community edition, then you can download a free trial of the very latest full RAD Studio C++ Builder version.

How To Run A C++ Program the C++ Logo

C++ Builder is the easiest and fastest C and C++ IDE for building everything from simple to professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

Download RAD Studio 11 Now

See What’s New in RAD Studio 11

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?