Site icon Learn C++

This Is How To Compile C++ Apps On Windows

How can I compile my C++ app code on Windows? How can I compile Modern C++ code on Windows? How can I compile C++ on Windows with visual UI elements? Let’s answer these questions.

If you are new to programming or even if you coming to C++ from another programming language, sometimes it is hard to understand how to write C_++ code, how to design the screens and how to compile and run your apps. In this post we will explain how to compile C++ code in Windows to produce Modern C++ applications in Windows.

The first thing we need is a modern IDE and C++ Compiler.

Did you know you can download the C++ Builder Community Edition for free?

Embarcadero’s C++ Builder CE, is a free C++ IDE and compiler suitable for the community of freelance developers, startups, students and non-profits, C++Builder Community Edition is a full featured IDE for building iOS and Windows apps from a single modern C++ codebase. It has a limited commercial use license. C++Builder Community Edition includes a code editor, powerful debugging tools, built-in access to popular local databases with live data at design time, Bluetooth and IoT capabilities and a visual UI designer with support for pixel perfect, platform specific styling.

Here are the features of the C++ Builder CE version;

The C++ Builder CE is the easiest and fastest C & C++ IDE for developing everything from simple to fully professional applications on a wide range of operating systems. It is also easy 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. C++ Builder is one of the most professional IDEs that works under RAD Studio.

You can download the FREE C++ Builder Community Edition (CE) here: https://www.embarcadero.com/products/cbuilder/starter.
Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. You can download and use the trial version for one month with the same capabilities as the full version . Please visit https://www.embarcadero.com/products/cbuilder.

How to Compile C++ on Windows?

If you download C++ Builder Community Edition (or RAD Studio CE version) or any Professional, Architect, Enterprise versions of C++ Builder. Install it on your Windows machine and run RAD Studio.

  1. Choose File->New-> “Console Application – C++ Builder” menu
  2. There will be New Console Application window. Set Target Framework to None for a standard console application and press OK as below

3. Save all Unit File and Project file to a folder.

4. inside the main() function add these lines

[crayon-662e112dae649263119029/]

or if you want you can clear all codes there and copy this standard C++ code to run

[crayon-662e112dae653954892438/]

This example above is a modern “Hello World” example on Windows which runs with C++ Builder. Modern applications have a GUI and they should be compatible with other operating systems other than just Windows – for C++ Builder this includes MacOS, iOS, and Android. FireMonkey projects are multi device, multi-platform, applications that you can compile and run on Windows, MacOS, iOS and Android.

5. Now you can compile this C++ code in Windows, press F9 key or just press Run button in the center of top bar.

6. You should see this below in a console application

[crayon-662e112dae655447260861/]

7. Note that C++ is case sensitive, so upper and lower characters should be also same.

8. Then press F9 key or just press Run button in the center of top bar.

Is there an example of how to create a Modern C++ “Hello World” example?

If you are a beginner “Hello World” examples are good to understand feature of that programming language. It helps explain how to edit text, how to write code in the new language, how to compile and link, how to debug and execute, and how to deploy or release. Now let’s create a Visual and Modern C++ Example

  1. Open C++ Builder or RAD Studio IDE
  2. Create a new MultiDevice Application in C++ Builder from File->New menu. This will allow you to develop multi-OS C++ apps with FireMonkey UI elements. Or you can create a new Windows VCL Application in C++ Builder. This will allow you develop C++ apps with VCL UI elements.
  3. Save all units and project files with “HelloWorld_” prefix in a HelloWorld folder.
  4. Add Memo (TMemo) and a Button (TButton) from the Palette to your Form. TMemo component is good to display all outputs as in console applications.
  5. Double click to Button to create OnClick() event, inside that Button1Click event write lines as given full example below,
[crayon-662e112dae657178064251/]

7. Run project by hitting F9 or click to Run with Debugging

Output should be like this.


8. If all is fine then save the project
9. if you check your header file you will see all your objects (Memo, Button etc. ) are automatically defined as below. You don’t need to change anything here

If you are a beginner “Hello World” examples are good to understand features of that programming language. It is good to understand how to edit text, how to write in its format, how to compile and link, how to debug and execute, how to deploy or release.

The code below is a modern “Hello World” example on Windows which runs with C++ Builder. Modern applications have a GUI and they should be compatible with other operating systems (Windows, MacOS, iOS, Android). FireMonkey projects are Multi Device (multi-platform) applications that you can compile and run on Windows, MacOS, iOS and Android.

If you want, you can switch to your header file (.h) of your cpp file (.cpp) from the button tabs. Your auto-generated header file of your Multi-Device Application will be shown as below,

[crayon-662e112dae65a721669864/]

C++ Builder is the easiest and fastest C and C++ IDE for building simple or 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.

Exit mobile version