In this post we explain simply how you can start to build Windows applications from a beginner’s level using a fast and reliable C++ Compiler. Once you have installed the C++ IDE it will literally take you less than 3 minutes to create, compile and run your very first C++ Windows app. Let’s try it together now!
Table of Contents
Which tool do I need to develop a Windows C++ app?
If you want to develop a Windows application using the C++ programming language, you will need a C++ IDE and C++ compiler so that you can edit and compile your code into an executable Windows application.
C++ is one of the World’s most powerful and popular programming languages. It has many ready-made variables, functions, methods, namespaces and libraries to enable you to write almost any app you could ever want. Using a fast and reliable C++ IDE and compiler is very important for beginners and professionals alike when they develop C++ apps for Windows and other operating systems. A good quality C++ IDE has features which help the developer through the process of writing, testing and debugging the code.
What is a C++ IDE and why is it important?
An integrated development environment (IDE) is a software application that provides a complete set of features for application development. Because programming code is generally written in a text format, you can, at the most fundamental level, edit or modify your code using text editors like Notepad, Word, WordPad, or the superb UltraEdit. However, for a developer, whether beginner or professional, an IDE is really important because it has C++ coding-specific features like syntax coloring, the highlighting of possible errors, automatic code completion and a great dedicated help system, along with the opportunity to run, test, debug, deploy, merge or transform code on other platforms (multiplatform coding).
Dedicated IDEs like RAD Studio and C++ Builder have a rich array of features specially designed to make the process of writing C++ programs as efficient as possible. They contain lots of functionality which goes above and beyond that of a simple text editor. These features include things like powerful form designers which allow you to design and lay out the screens of your C++ app, ‘intelligent’ items like code completion, refactoring, navigation which understands the structure of your code so that it can jump to relevant sections of your program with a simple click, component sets such as the VCL and FireMonkey FMX which nicely encapsulate ready-made program and GUI functionality saving you the time and effort in having to write it from scratch, as well as all sorts of other helpers, tools and add-ins to make the coding experience as smooth as it can be.
A simple text editor has none of this and is simply no comparison to a proper, purpose-built C++ IDE.
Start with downloading the free C++ Builder Community Edition
If you are new to C++ and want to compile code for the first time we recommend you try the free C++ Builder Community Edition for students, beginners, and startups. 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. C++ Builder comes with Rapid Application Development Studio, also known as RAD Studio, and C++ Builder is one of the most professional IDE’s that work under RAD Studio. More details about C++ Builder & RAD Studio for the beginners can be found in Official Wiki of Rad Studio.
Here are the features of the C++ Builder CE version;
- Build Windows and iOS C++ Applications 10x Faster with Less Code.
- C++Builder Community Edition provides you with an integrated toolchain and professional-level developer tools from Day 1
- Featuring Clang-enhanced compiler, Dinkumware standard library, MSBuild/CMake/Ninja support, and popular libraries like Boost and Eigen.
- Develop Windows and iOS applications with a single codebase and responsive UI
- Enjoy the award winning Visual Designer using the C++Builder VCL and FireMonkey frameworks for maximum productivity
- Built-in Debugging Tools that allow you to debug on any device
- Build database apps with local/embedded capabilities
- Hundreds of included components to enhance your app and reduce development cycles
- Direct access to InterBase, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, DB2, SQL Anywhere, Advantage DB, Firebird, Access, Informix, MongoDB, and more.
- Licensed for use until your individual revenue from C++Builder applications or company revenue reaches $5,000 US or your development team expands to more than 5 developers
How to compile Firemonkey Windows C++ Applications?
How do I create a new C++ project?
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 computer and run RAD Studio or C++ Builder. Beginners and students normally start to learn C++ with simple code.
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, this means you don’t need VCL or FMX frameworks, you create a console application too. Modern applications have a GUI’s and skinned Styles. Note that VCL projects are Windows only and FireMonkey 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 design the screens for a C++ app?
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 which by default is on the left side of the IDE screen.
Note that you can switch between the GUI Design mode to Code Mode by pressing F12, or vice versa.
How to add C++ code to a project?
Double click to Button1 to create OnClick() event for this button. Add these lines into Button1Click() event,
This example above is a modern “Hello World” example for Windows which runs with C++ Builder.
How to compile your C++ project?
Now you can compile this C++ code; just press the F9 key or just click the Run button in the center of top bar. This will let the IDE check your code and compile both the Unit and project files and link them together. You can also use the Run menu from the top to run your application.You should see this below as a form application
If you get an error, check your code – it’s easy to mistype or have the braces (“}” characters) in the wrong place. The IDE may be able to underline errors with red ‘squiggly’ lines. Note that C++ is case sensitive, so upper and lower characters should be also same. Then press the F9 key or just click the Run button again.
From this point, you can add more code or you can switch back to design mode by pressing F12. And you can add more components, then more code. This is how modern C++ coding works with an UI Toolkit.
How to compile VCL Windows C++ applications?
If you succeed in the steps above and want to know how to compile modern and visual application in VCL, you can do same with a VCL application. Note that VCL applications are only for Windows operating system, you can not compile for other operating systems. There are slight changes between VCL and FMX components.
Now let’s create a Visual and Modern C++ example in C++ Builder,
- Open C++ Builder or RAD Studio IDE
- Create a new Windows VCL Application in C++ Builder from File->New menu. This will allow you develop C++ apps with VCL UI elements.
- Save all units and project files with “HelloWorld_” prefix in a HelloWorld folder.
- Add a Memo (TMemo) and a Button (TButton) from the Palette to your Form. TMemo component is good to display all outputs as in console applications.
- Double click the Button to create OnClick() event, inside that Button1Click event write lines as given in the example below,
- Run project by hitting F9 or click Run with Debugging
- If there is error, please check your lines
- If all is fine then save all project
- 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, and how to deploy or release the finished program.
This example below is a modern “Hello World” example on Windows which runs with C++ Builder.
If you want, you can switch to your header file (.h) of your cpp file (.cpp) from the button tabs.
The latest posts along with more examples and tutorials can be found here on the Embarcadero Blog with this dynamic search https://blogs.embarcadero.com/?s=C%2B%2B and in LearnCPlusPlus.org.
Why not download a free trial of the latest full version of C++ Builder today?