본문 바로가기

Programming/C++ Basic

[Basic C++] 01 - How to get MS Visual Studio 2019 and create projects

I am going to write C++ basic tutorials during my C++ study.


In this example, I am going to cover how to get Microsoft Visual Studio 2019 (MSVS) for free. Visual Studio has normally three different editions, which are Community, Professional, and Enterprise. The other two editions are not free except for the community edition. Unless you are going to develop industrial software within a large team project, the community version is just fine.

 

In order to use the community edition, you have to sign in your visual studio to get your license authorized first, otherwise, you can only use it for 30 days maximum.

 

Figure 1 Compare visual studio editions.

 

1. Step 1: Download MSVC 2019

Download MSVC 2019 from the below URL.

 

Download Link >>

https://visualstudio.microsoft.com/en/vs/?rr=https%3A%2F%2Fwww.google.com%2F

 

2. Step 2: Select Products

MSVC 2019 download install manager will ask you what to install first and check only pakages you really need, otherwise your drive will be filled up with some random files you don't really need to use. Mine is Japanese simply because I live in Japan.

 

I have choosen C++ / desktop developmet pakages with .Netframework / C# for more API development. MSVC 2019 also supports python, but I'd rather use Pycharm for Python.

 

Figure 2 MSVC 2019 installer

 

3. Step3: Create a new project

Not only MSVC but also any other IDEs requires you to create a project before you actually code. Projects are simply like containers for your codes and peripheral files.

 

Figure 3 Crating a project

Click "Create a new project" down below.

 

Figure 4 Crating a project

MSVC 2019 provies hunderes more project options depending on the porpose of your program, but here you simply choose either "Empty Project" or "Console App". 

 

Figure 5 Crating a project

Define project name, location and solution name. One might wonder what a "SOLUTION" is. A solution is also a container like a project but it contains mutiple project. The gloa of creating a soluton is to manage multiple projects created for different functional purposes. The name "Soluton" might differ depending on what IDE you would use. It is just what MSVC likes to use.

 

Figure 6 Solution Explorer

Figure 6 shows the solution exlporer on my MSVC 2019. You can clearly see the hierarchy between a soluton and a project. It's is very importatant to undestand how they work if you are in a huge team, but in this stage, let's put aside it. Anyway now you have a project.

 

4. Step4 : Creating source files

It is the last step to code C++ in MSVC 2019. Go to the solution Exporere and right click "Source files" -> Add -> New item -> C++ File.

 

Figure 7 Creating source files

Now you can code C++ on the newly created source file. The below example is a simple "Hello World" code. C++ and Python are both object-oriented progarmming languages, but there are significant differnece between two of them. I won't write down all of them here of course, but one thing you must know is that C++ needs this specific process called "Compile". Compile is the process of creating a program from code so your computer can run it. This also means that it is platform-dependent. If you compile code in Windows, you can't run it in Mac.

 

If you press Ctrl+F5, MSVC executes "Build and Run" function to complie your code. Build is a process of compling and Run is just running a program.