Do you want to get started with C++? This is the right place for you!
C++ is essential in game and software development, especially when using powerful engines like Unreal Engine.
Learning C++ is extremely valuable because it provides game developers with precise control over their creations. It will allow you to write code that directly interacts with the hardware of the computer, resulting in faster and more efficient performance. By mastering C++, you can unleash your creativity and take game development to new heights.
Unreal Engine, a widely used game engine, written in C++ and includes a wide range of libraries and tools to help with game development. So, if you’re eager to dive into the exciting world of game development, learning C++ is an essential step towards realizing your game development dreams. Let’s get started!
C++ Install IDE: Visual Studio
An IDE is the first thing you’ll need to get started programming in C++.
When programming in C++, using an Integrated Development Environment (IDE) rather than a simple text document has numerous advantages.
An IDE is a collection of tools and features that are specifically designed to improve your coding experience. An IDE provides features such as code completion, syntax highlighting, project management, and automatic error checking, which significantly speed up development and reduce the likelihood of errors.
I recommend you installing Visual Studio Code and Visual Studio Community. Make sure to install both programs. If you are unaware, Visual Studio Code has a browser version.
During the Visual Studio Community installation select “Desktop development with C++“. If you want, you can also select “Game development with C++” and “Mobile development with C++“.
Then go to Visual Studio Code Extensions and install Microsoft’s C/C++ extension.
C++ Compiler: MinGW
Installing a compiler, such as MinGW (Minimalist GNU for Windows), is essential for C++ programmers because it allows them to convert human-readable C++ code into executable programs that can be run on a computer.
A compiler converts high-level language code, such as C++, into low-level machine code that the computer can understand and execute.
If you are curious about C++ compilers and their features, you can visit the cppreference website.
How to install MinGW W64 for Windows?
- Go to the MinGW website.
- Select the “MingW-W64-builds” download.
- Click on “Installation: GitHub“.
- Download the “x86_64-13.1.0-release-posix-seh-msvcrt-rt_v11-rev1“. Or a newest version.
- Extract the files in your PC, and save them in a secure folder. Like in your C hard drive.
- Search in Windows “Edit the system environment variables“.
- It should not be confused with “Edit environment variables for your account“.
- On the advanced tab, select “Environment Variables…“
- In the System variables section select “Path“, click on the “Edit…” button.
- Then click on “New” and paste or write the path to the folder where the compiler was extracted.
- For example: C:\Program Files\mingw64\bin
- Close all windows pressing “Ok”.
To verify if you installed the compiler correctly, type “CMD” into the Windows search bar. Then enter:
g++ --version
If your result looks like the image below, you are ready to get started with C++!
If you need more help, check out this tutorial:
Run C++ Code
Now that the installation is complete, it’s time to configure and test some C++ code.
- Inside Visual Studio Code, make a project folder in the explorer and a .cpp file.
- Then go to Terminal–> Configure Tasks –> and select the g++.exe compiler.
- If you did everything correctly, two files will be generated: tasks.json and launch.json.
- For C++ 20 compatibility, add the line of code “-std=c++20” inside “args” in tasks.json, as shown:
"args": [
"-fdiagnostics-color=always",
"-std=c++20",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
]
Finally, click Terminal –> Run task… this should result in the creation of an .exe file.
This can be a difficult step to understand, so I recommend reading this Microsoft Tutorial and watching the first half hour of the following C++ course.