Download and execute
the Visual Studio 2022 Installer from the Microsoft website. Then selectVisual Studio Community 2022
and click on theInstall
button. If youalready installed
Visual Studio 2022, you can move on tostep 4
.
- You will be asked to select the packages you want to install. This tutorial is for C++ but you can select other packages if you like. The basic C++ package you should install is the one called
Desktop development with C++
(which is not necessarily for desktop only as I use it to develop for other platforms too).
- 2.1 I recommend to also go to the
Individual components
tab and select theGit extension
orGit for Windows
that comes with it (until VS2019 you had both).
- When opening VS
for the first time
, a menu will let you chooseVisual C++
as yourdefault setting
. *
- A
folder
will be needed where your development solutions will be placed. I called mine justsolutions
.
- You can then create a new solution and project as follows:
- 5.1 Open Visual Studio 2022 and click on
Create a new project
:
- 5.2 Select
Windows Desktop Wizard
as project template, then click onNext
.
- 5.3 Then type the Project name (such as
MyFirstProject
) and the name of the folder in theLocation
box, then click onCreate
.
- 5.4 In the window that pops-up next, select
Console Application
as theApplication type
and check theEmpty Project
checkbox.
- 5.5 Click on
OK
and the project and project files will be created automatically as shown below.
- After setting up the project, you will be able to add files to it from the samples you find here or browsing the web. If you want to
test
some code you can write ahello world example
as follows:
- 6.1 Right click on the
project name
in theSolution Explorer
inVisual Studio
(at the right or left of the edit area) and in the pop-up menu selectAdd
->New item
- 6.2 Select
Visual C++
->C++ file (.cpp)
and type the name of the file, such asmain.cpp
at the name box. Then Click onAdd
to create the file.
- 6.3 Type or copy the following code into the
main.cpp
file:
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}
- 6.4 Press
F7
(orctrl
+shift
+b
if you didn't set up Visual C++ settings) to build the executable andF5
to execute in debug mode.