About us

Breaking

2021/04/22

How to Setup C++ on Windows

In order for us to write programs in C++ we need to have a computer and then a set of tools that will let us build C++ programs. These tools of course are going to depend on which operating system you're using. So this article is going to cover Windows but if you're using Mac or Linux then in the next article we will cover those because Windows is the most widely used operating system in the games industry. Now to write C++ code all you really need is just some kind of text editor like notepad for example will do fine however once you've written that code in C++ as a text file we need to take that and pass it through a compiler to generate some kind of executable binary so that we can run our program. what we need at the very minimum is a compiler that will take that text that we've written and convert it into a program. 

However we can do a lot better than that. Writing C++ isn't the easiest task and if you're using something like notepad it's really just gonna not help you at all. So what you can do instead is actually get a development environment something called an integrated development environment this is basically a set of tools that helps you write and debug your code in our case. Since we're on Windows we're gonna be using something called Microsoft Visual Studio which is pretty much the best idea out there. Now don't think that it's perfect but it is the best thing that we've got. We used a lot of different IDs .Visual Studio has plugins that will help you target pretty much any platform like PC, mobile consoles everything which is why it's the most popular idea in the games industry. 

 


 

You need to have Windows 10 doesn't really matter what version of Windows you're using.You need to go to VisualStudio.microsoft.comm link download Visual Studio and you're gonna get community 2019. Now Visual Studio community is absolutely free and once it's downloaded you need install that and installing Visual Studio will take a significant amount of time. so you might want to come back Now this is Visual Studio 2019 which is which is quite a bit better than 2015 and 2017. It's a lot
faster and it has some pretty nice new features and it's also going to be the idea that we use for the entirety of this series.
 
 
Now there is actually a plug-in called vigil assist which you need to use all the time. Don't use Visual
Studio without visual assist. It's amazing now it does cost money it's like $99 for a personal license but if you do write a lot of code in Visual Studio it's amazing it basically just gives you a lot of features the Visual Studio is missing. Visual Studio 2019 has this brand new install that has like a lot of things way more than 2015 or 2017. 
 
 


 
What we really want is the easiest way to go through this is just to pick desktop development with C++ that includes pretty much everything you need. We don't need Universal Windows platform development which is actually something entirely different something that you probably want and still if you're using stuff like C sharp you might need to install net desktop development. This series is gonna be C++ desktop development.  Just to click on desktop development with C++ and be done with it.

 

Hit install and now it's gonna start downloading and installing everything we need so this will really take a while. Now the visual studio is installed let's go ahead and launch it. You can either click launch where you can you know get rid of this and then click launch it's up to you. You're gonna login with your account. Now you will see the start page and the things that you like to get done out of the box. 
 

 
You like to customize your  settings and stuff like that for example under tools options you can go and change to dark mode for example there's a color theme you can just go ahead and change that to dark because it's actually already loaded with settings just from the cloud and everything now you've to do is to set up visual studio.
 
It including like the syntax highlighting theme and everything. You want under general settings it
hasn't done everything but I mean the default option is usually pretty good just hit finish and everything should work now. If you don't have visual assist installed you might get some warnings. Just make sure everything works by creating a new solution. You can actually click on there's a bunch of photo templates we're gonna go file new project and then under visual C++ under general they'll be a template called empty project. We're gonna select that put it any way you like put it into C dev you've to actually made a folder for it inside C Dev in and CPP series. This path is huge second of all. you'll see this path actually has a space in it which will cause problems with some plugins for example some components of NVIDIA's Android plugins for visual studio actually just won't work if your path has a space in it so that's already bad news. Also this puts it in your users directory which isn't really necessary so just see dev and then whatever your project is so in this case.We're literally just gonna write a little hello world application that will print hello world to the console and test our our entire tool chain.
 

 
 
Now you'll see there's also something called a solution name Visual Studio.  Visual Studio has solutions and projects. Think of a solution as like a group of projects that are related to each other they can be
various project types. Basically a solution is like your work bench and then each project is essentially just a group of files which compiled into some kind of target binary whether that be a library or an actual executable. So that looks pretty good. We should be taken into our project you have solution Explorer on the Left side of the window all you have to do is right click on source files hit add new item under C++ file. Now  just go to call it main.cpp hit add then  type 
 
#include <iostream>
int main()
{
    std::cout <<  "Hello world!" << std :: end1;
    std::cin.get();
}

and hit build we'll have our output window show up and make sure that everything succeeded there you
can see that is generated a helloworld.exe file which is an executable binary for windows and now you can run it either by going to this directory in fact let's let's take a look at this directory. We can either run it by just double-clicking and you can see there's our application color world and if we press any key then well if we press enter it will terminate all we can run it by just clicking on local windows
debugger which will actually build and run it. So there you go and we're actually debugging the code  so that's it we've got application running. We've written our first application in C++ and we've verified that our tools work properly. 
 


 

No comments:

Post a Comment