BEST Visual Studio Setup for C++ Projects!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys my name is eterno welcome back to another video Gama coffee means I can make a video now so today I thought I would kind of just make a little video it's going to be a small one kind of a midweek thing for you guys well I just I just wanted to talk about something that I didn't feel would take that long that being said the amount of videos that I started off being like this is going to be a short video and then it's ended up being something that's like half an hour long has been like I mean all of them really but today we're just going to talk about the way that I set up my say plus projects these aren't necessarily going to be the best settings for everyone Tampa however it is what I use it's what I've kind of learned like grown into using over the years and honestly every single service loss project or like and I'm not just talking about a single project I'm talking about like a whole solution of projects so every single one that I create from now on pretty much I use these settings so let's just let's just jump in and take a look so we've just opened Visual Studio we've got our start page here nothing's I haven't opened any kind of solution yet I'm going to create a brand new project and solution here by hitting file new and then project for now I'm just going to go onto Visual C++ general and create an empty project and then I'll just call it something like new project now in terms of the location I like to store the projects that I develop under the seed directory and not inside the user folder that way when I'm switching computers or anything like that it's not going to break any parks and really it's just a lot easier to kind of store your development project in some kind of central directory so I like to do something like say flash dev and then maybe we'll call it new project or something like that now because we've got create directory resolution it will actually automatically create that new project folder so I need to write that I'll just hit OK and we'll see what happens I'm sure it's taking a while okay so once we've got this new empty project you can see we have absolutely no files here or anything like that if I right-click on the actual project and hit open folder in File Explorer you'll see the actual directory structure the visual studio has created for us so what we've actually got is inside that dev folder we've got that new project we've got a solution file right next to there you can see that also what studio has done it is called our solution the exact same as our project so that's not necessarily something that you want if this is just going to be a solution with a single project in it then maybe it is but you know if we're making like a game or something then it's very very rare for us to kind of want our solution and project name to be identical but anyway this structure is actually not bad we've got a folder dedicated for our for our project we've got both a VCF profile and a filters file I'm not going to get too in-depth about all the different files Visual Studio create now might be an idea for another video but basically the VCF approach is our project file which is just an XML file and then we've also got a solution file which is it's only kind of weird format it's the text folder and that's in a certain kind of directory okay cool I actually like this structure I'm not going to change it too much but you'll notice that also what we get here is a bunch of various folders now these are not folders right there are things called filters filters are not folders if I right click on new project here and do ad you'll see there's no new folders new filter and if I add a filter called journal or something nothing is going to change on our disk that's not the way that it works this filters file however does contain these kind of virtual folders that we create so these are fantastic such as organizing your source code within folders that don't actually exist on disk but they do exist in this solution Explorer view so if I was to go into source files for example and add a new item source files is in a folder so if I add an item with something called main dot CPP once it creates the file and everything you'll see that it's actually just created that right here next to my project and that's just I just that's just that's just messy right well look what why so what I like to do is I like to create a folder called source or SRC which contains all of my source code and header files and all that stuff kind of in that folder so that my project files and any other resources that I might be using in my project are actually kind of actually separated into folders and that's something that the visual studio doesn't set up for you automatically so you kind of have to roll with it so if we go back to visual studio we can click on our project here and a little button will appear here which says show all files if we click that this view this view is actually your directory structure that is on your disk on your harddrive so I right click now and hit add you'll see the filter is replaced with new folder and I can actually make a folder called case I'll see right if I alt tab back to my file explorer look at that we've got a folder called source let's move this mendosa TP file into that source directory now I can do so using Windows Explorer which would mean that I would have to manually update it in Visual Studio or I can just click and drag it like that and you can see that on disk is actually moved it into that directory okay so now Visual Studio is actually behaving a little bit more like I would like it to so this kind of show all files button is incredibly useful and honestly I kind of use that mostly if we go back to our filters you can see that main is still inside the source files this is just a virtual organization kind of scheme right I can drag this to header files it doesn't matter where this is right it could be just in no filters which would make it here I can just go ahead and delete all these in fact it doesn't really matter these this filter view is all just it's all fake right it's all just kind of there for you to just organize things into groups it has no no relation to actual directory structure on disk so if I go back to Cheryl files mode there is my main dot CPP file and I can do all of my code here let's go ahead and just write a quick hello world program just something for us to build all right now I'm going to compile this so I right click on my projects build and you can see that everything will build successfully so we're his visual studio put our exe file if we look at the output you can see it's gone it's a new project and debug a new project Exe so debug being our currently selector configuration if we open our file explorer once again and we check this out so it hasn't actually you can see that the debug folder here which is in the same directory as obviously X profile however if we open it I don't see no no new project or Exe in here right so what's going on here we registered in more first it looks like it's just new project then debug so it's not in that project folder hah interesting let's go back to new project and then go back again and then debug and then oh it's in here how strange visual studio so what's actually happened is it put our intermediate files into a folder called debug in our project directory and our actual final executable binary into a folder called debug in our solution directory I don't know who makes this stuff up it's really quite annoying I have not actually met any professional developer who leaves these settings everyone changes them because they're just honestly they are weird now it's not a really big problem to change these and you can create templates and stuff like that but I'm not roasting Microsoft too much for deciding to do this I'm just saying that it's a little bit weird and especially for people kind of starting out who might not know that you can change this you could actually be quite difficult to find your damn executable binary once you built it so anyway so if we go back to the digital studio if we right-click on our project and here properties you'll see that on the active under our active configuration of platform we have an output directory and we have an intermediate directory so that's actually where everything is going so you can see that everything that we write here by the way is going to be relative to the project file so if I put something like intermediate here is going to be relative to that project file so in the same directory as our project file which is this VTX project file it will actually make a folder called intermediates in this case and put them all there ok so what I like to change this to now first of all I like to go to all configuration so that I'm editing all configurations and we're not going to make any any imma go seven interchanges that are made here even all platforms ok and then what I like to do is this for my output directory I like to put my output directory in my solution directory slash bin slash platform and then slash configuration and then end that with a slash as well ok so what it's going to do in our case is put this into the solution directory which is the root of this whole thing what that means and the reason I've actually chosen a solution directory is because if we have multiple projects right for example we build dll files or something that are needed by our main application we want them all to be in the same folder right I don't want to have to go into every project folder and then deal with that I just want all of my built binaries in one place because that's usually the typical case you want them all there so they're going to be in my solution directory in a folder called bin which types of binaries in the appropriate platform folder so in our case really it will only be win32 or axe 64 and then inside a configuration so either debug or release in our case now this last part putting it into a separate folder for each configuration again not something that I do all the time sometimes I just like to change the target name to maybe have debug appended to it for the debug build and potentially release or nothing at all depended to it for the release build if it varies honestly based on how I how I deal with my projects but in this case I'm just going to put them into a separate folder now intermediate directories are going to be very similar I'm going to put I'm going to I'm just going to copy everything from the output directory put it into the intermediate directory the only difference is that inside bin I'm going to make a folder called intermediate and then put them there by platform by configuration again sometimes I put this intermediate folder at the very end so there's already inside everything but this way it's just a little bit cleaner for you to be able to copy save the platform that you want and only have all the built binary is no intermediate files so if I now see it okay right we can clean our project which should get rid of a lot of the previous files if not because it never really does works out well I like to go into the file explorer and just delete all of these files that I don't care about so all the debug directory you can see that now I'll even delete this bin directory you can see that now all we have is the solution file the project we've got the project filters and a user file which is just basically our current Visual Studio configuration and then in source we've got maintance is nice and clean I'm going to go back to visual studio and I'm going to build alright cool so if we go back here we go to bin we can see we've got intermediate and then win32 so inside intermedius legal win32 debug that's all of our intermediate files such as our obj files and then if we go back you can see we've got win32 debug and then that is our exe file and we can run that and everything's fine all right cool one little thing as well you can see that we've got a double backslash here because of course I did forget that the solution directory anything that has like project directory or solution directory actually has a backslash on it already because it's a directory name so just go back and fix that up so that we don't get a double backslash if you're not sure what one of these macros is equal to or you would like to see what it is you can just go under edit here then we can expand this mappers view and then over here we've got everything we want to for example that solution directory what I was talking about you can see it's CDF new project and you can see delve in fact and with a backslash all right cool so that's pretty much it that's all I just wanted to say setting up your directory is really important really quick tip that will just kind of make your life easier as far as organization goes these are the settings that I use all the time we might talk about more or less the compiler settings and linking settings and all other kind of maybe release might optimization settings in another video I just wanted to show you guys the basis of how I setup every new super sauce project that I do do you guys enjoy this video please hit that like button follow me on Twitter and Instagram and and I will see you guys in the next video goodbye [Music] [Music]
Info
Channel: The Cherno
Views: 296,284
Rating: 4.9107265 out of 5
Keywords: visual, studio, setup, c++, development, gamedev, thechernoproject, cherno, tutorial
Id: qeH9Xv_90KM
Channel Id: undefined
Length: 12min 7sec (727 seconds)
Published: Wed May 24 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.