YouTube2Text

BEST Visual Studio Setup for C++ Projects! — Transcript

by The Cherno · 2,605 words · 366 segments · language en · Watch on YouTube

Full transcript

  1. 0:04[Music]
  2. 0:06Hey, what's up guys? My name is Aerno.
  3. 0:08Welcome back to another
  4. 0:10video. Got my coffee means I can make a
  5. 0:13video now. So, today I thought I would
  6. 0:15kind of just make a little video. It's
  7. 0:18going to be a small one. Kind of a
  8. 0:19midweek thing for you guys where I just
  9. 0:21I just wanted to talk about something
  10. 0:23that I didn't feel would take that long.
  11. 0:25That being said, the amount of videos
  12. 0:26that I've started off being like this is
  13. 0:28going to be a short video and then it's
  14. 0:30ended up being something that's like
  15. 0:32half an hour long has been like I mean
  16. 0:34all of them really. But today we're just
  17. 0:36going to talk about the way that I set
  18. 0:37up my C++ projects. These aren't
  19. 0:40necessarily going to be the best
  20. 0:42settings for everyone ever. However, it
  21. 0:44is what I use. It's what I've kind of
  22. 0:45learned like grown into using over the
  23. 0:48years. And honestly, every single C++
  24. 0:50project or like and I'm not just talking
  25. 0:52about a single project. I'm talking
  26. 0:53about like a whole solution of projects.
  27. 0:55For every single one that I create from
  28. 0:57now on, pretty much I use these
  29. 0:59settings. So, let's just let's just jump
  30. 1:00in and take a look. So, we've just
  31. 1:02opened Visual Studio. We've got our
  32. 1:03start page here. Nothing's I haven't
  33. 1:05opened any kind of solution yet. I'm
  34. 1:07going to create a brand new project and
  35. 1:08solution here by hitting file, new, and
  36. 1:11then project. For now, I'm just going to
  37. 1:12go under Visual C++ General and create
  38. 1:15an empty project. And then I'll just
  39. 1:16call it something like new project. Now,
  40. 1:20in terms of the location, I like to
  41. 1:21store the projects that I develop under
  42. 1:23the C directory and not inside the user
  43. 1:25folder. That way, when I'm switching
  44. 1:27computers or anything like that, it's
  45. 1:28not going to break any paths. And
  46. 1:29really, it's just a lot easier to kind
  47. 1:31of store your development projects in
  48. 1:32some kind of central directory. So, I
  49. 1:34like to do something like C/dev and then
  50. 1:36maybe we'll call it new project or
  51. 1:38something like that. Now, because we've
  52. 1:40got create directory for solution, it
  53. 1:41will actually automatically create that
  54. 1:42new project folder. So, I don't need to
  55. 1:44write that. I'll just hit okay and we'll
  56. 1:45see what happens.
  57. 1:50I'm sure it's taking a while. Okay, so
  58. 1:52once we've got this new empty project,
  59. 1:54you can see we have absolutely no files
  60. 1:56here or anything like that. If I right
  61. 1:57click on the actual project and hit open
  62. 2:00folder in file explorer, you'll see the
  63. 2:02actual directory structure that Visual
  64. 2:04Studio has created for us. So what we've
  65. 2:06actually got is inside that dev folder,
  66. 2:08we've got that new project. We've got a
  67. 2:09solution file right next to there. You
  68. 2:11can see that also what Visual Studio has
  69. 2:13done is it's called our solution the
  70. 2:15exact same name as our project. So
  71. 2:17that's not necessarily something that
  72. 2:20you want. If this is just going to be a
  73. 2:22solution with a single project in it,
  74. 2:24then maybe it is. But, you know, if
  75. 2:26we're making like a game or something,
  76. 2:27then it's very it's very rare for us to
  77. 2:29kind of want our solution and project
  78. 2:31name to be identical. But anyway, this
  79. 2:34structure is actually not bad. Um, we've
  80. 2:36got a folder dedicated for our for our
  81. 2:38project. We've got both a VCX project
  82. 2:40file and a filters file. I'm not going
  83. 2:42to get too ind depth about all the
  84. 2:43different files Visual Studio creates.
  85. 2:45That might be an idea for another video,
  86. 2:46but basically the VCX project is our
  87. 2:49project file, which is just an XML file.
  88. 2:51And then we've also got a solution file,
  89. 2:53which is its own kind of weird format.
  90. 2:55It's a text file, though. Um, and that's
  91. 2:57in its own kind of directory. Okay,
  92. 2:59cool. I actually like this structure.
  93. 3:00I'm not going to change it too much, but
  94. 3:02you'll notice that also what we get here
  95. 3:04is a bunch of various folders. Now,
  96. 3:06these are not folders, right? These are
  97. 3:08things called filters. Filters are not
  98. 3:10folders. If I right click on new project
  99. 3:12here and do add, you'll see there's no
  100. 3:14new folder. It says new filter. And if I
  101. 3:16add a filter called churno or something,
  102. 3:18nothing is going to change on our disc.
  103. 3:20That's not the way that it works. This
  104. 3:21filters file, however, does contain
  105. 3:23these kind of virtual folders that we
  106. 3:25create. So these are fantastic for just
  107. 3:27organizing your source code within
  108. 3:28folders that don't actually exist on
  109. 3:30disk, but they do exist in this solution
  110. 3:33explorer view. So if I was to go into
  111. 3:35source files, for example, and add a new
  112. 3:37item, source files is in a folder. So,
  113. 3:39if I add an item or something called
  114. 3:41main.cpp, once it creates the file and
  115. 3:43everything, you'll see that it's
  116. 3:44actually just created that right here
  117. 3:45next to my project. And that's just I
  118. 3:47just that's just that's just messy,
  119. 3:49right? What like what why? So, what I
  120. 3:51like to do is I like to create a folder
  121. 3:53called source or src, which contains all
  122. 3:55of my source code and header files and
  123. 3:57all that stuff kind of in that folder so
  124. 3:59that my project files and any other
  125. 4:01resources that I might be using in my
  126. 4:03project are actually kind of nicely
  127. 4:04separated into folders. And that's
  128. 4:06something that that Visual Studio
  129. 4:07doesn't set up for you automatically. So
  130. 4:09you kind of have to roll with it. So if
  131. 4:10we go back to Visual Studio, we can
  132. 4:12click on our project here and a little
  133. 4:14button will appear here which says show
  134. 4:16all files. If we click that this view,
  135. 4:20this view is actually your directory
  136. 4:24structure that is on your disk that is
  137. 4:26on your hard drive. So if I right click
  138. 4:28now and hit add, you'll see the filter
  139. 4:29is replaced with new folder and I can
  140. 4:32actually make a folder called src.
  141. 4:34Right? If I alt tab back to my file
  142. 4:36explorer, look at that. We've got a
  143. 4:37folder called source. So, let's move
  144. 4:39this main.cpp file into that source
  145. 4:41directory. Now, I can do so using
  146. 4:43Windows Explorer, which would mean that
  147. 4:44I would have to manually update it in
  148. 4:46Visual Studio. Or I can just click and
  149. 4:47drag it like that. And you can see that
  150. 4:49on disk, it's actually moved it into
  151. 4:51that directory. Okay. So, now Visual
  152. 4:53Studio is actually behaving a little bit
  153. 4:54more like I would like it to. So, this
  154. 4:56kind of show all files button is
  155. 4:59incredibly useful and honestly, I kind
  156. 5:01of use that mostly. If we go back to our
  157. 5:03filters, you can see that main is still
  158. 5:05inside the source files. This is just a
  159. 5:07virtual organization kind of scheme,
  160. 5:11right? I can drag this to header files.
  161. 5:13It doesn't matter where this is, right?
  162. 5:14It could be just in no filters, which
  163. 5:16would mean it's here. I can just go
  164. 5:18ahead and delete all of these. In fact,
  165. 5:20it doesn't really matter. These this
  166. 5:22filter view is all just it's all fake,
  167. 5:25right? It's all just kind of there for
  168. 5:27you to just organize things into groups.
  169. 5:29It has no no relation to actual
  170. 5:32directory structure on disk. So, if I go
  171. 5:34back to show all files mode, there is my
  172. 5:36main.cpp file and I can do all of my
  173. 5:38code here. Let's go ahead and just write
  174. 5:40a quick hello world program. Just
  175. 5:42something for us to build. All right.
  176. 5:43Now, I'm going to compile this. So, I'll
  177. 5:44right click on my project, hit build,
  178. 5:46and you can see that everything will
  179. 5:48build successfully. So, where has Visual
  180. 5:51Studio put our .exe file? If we look at
  181. 5:53the output, you can see it's gone to new
  182. 5:55project, then debug, then new
  183. 5:56project.exe. So, debug being our
  184. 5:58currently selected configuration. If we
  185. 6:00open our file explorer once again and we
  186. 6:03check this out. So it hasn't actually
  187. 6:05you can see there's a debug folder here
  188. 6:07which is in the same directory as our
  189. 6:08VCS project file. However, if we open
  190. 6:10it, I don't see no no new project.exe in
  191. 6:14here, right? So what's going on here? If
  192. 6:15we read this a bit more closely, looks
  193. 6:16like it's just new project then debug.
  194. 6:18So it's not in that project folder. Huh.
  195. 6:20Interesting. So let's go back to new
  196. 6:22project and then go back again and then
  197. 6:24debug and then oh it's in here. How
  198. 6:27strange. Visual Studio. So, what's
  199. 6:29actually happened is it's put our
  200. 6:30intermediate files into a folder called
  201. 6:33debug in our project directory and our
  202. 6:36actual final executable binary into a
  203. 6:38folder called debug in our solution
  204. 6:40directory. I don't know who makes this
  205. 6:42stuff up. It's really quite annoying. I
  206. 6:45have not actually met any professional
  207. 6:48developer who leaves these settings.
  208. 6:51Everyone changes them because they just
  209. 6:54honestly they are weird. Now, it's not a
  210. 6:56really big problem to change these and
  211. 6:57you can create templates and stuff like
  212. 6:59that. So, I'm not roasting Microsoft too
  213. 7:01much for deciding to do this. I'm just
  214. 7:03saying that it's a little bit weird and
  215. 7:04especially for people kind of starting
  216. 7:06out who might not know that you can
  217. 7:07change this. It's it could actually be
  218. 7:10quite difficult to find your damn
  219. 7:11executable binary once you've built it.
  220. 7:13So anyway, so if we go back to Visual
  221. 7:16Studio, if we right click on our project
  222. 7:18and hit properties, you'll see that
  223. 7:21under active under our active
  224. 7:23configuration and platform, we have an
  225. 7:25output directory and we have an
  226. 7:27intermediate directory. So that's
  227. 7:28actually where everything's going. So
  228. 7:29you can see that everything that we
  229. 7:31write here, by the way, is going to be
  230. 7:32relative to the project file. So if I
  231. 7:35put something like intermediates here,
  232. 7:38it's going to be relative to that
  233. 7:40project file. So in the same directory
  234. 7:42as our project file which is this VCX
  235. 7:44project file it will actually make a
  236. 7:46folder called intermediates in this case
  237. 7:47and put them all there. Okay. So what I
  238. 7:49like to change this to now first of all
  239. 7:51I like to go to all configurations so
  240. 7:52that I'm editing all configurations. I'm
  241. 7:54not going to make any any I'm not going
  242. 7:56to save any of these changes that I made
  243. 7:57here. Um even all platforms. Okay. And
  244. 8:00then what I like to do is this for my
  245. 8:02output directory. I like to put my
  246. 8:04output directory in my solution
  247. 8:07directory slashbin
  248. 8:10slashplatform and then slash
  249. 8:12configuration and then end that with a
  250. 8:15slash as well. Okay, so what it's going
  251. 8:17to do in our case is put this into the
  252. 8:19solution directory which is the root of
  253. 8:21this whole thing. What that means and
  254. 8:24the reason I've actually chosen solution
  255. 8:25directory is because if we have multiple
  256. 8:28projects, right, for example, we build
  257. 8:30DLL files or something that are needed
  258. 8:32by our main application, we want them
  259. 8:34all to be in the same folder, right? I
  260. 8:36don't want to have to go into every
  261. 8:37project's folder and then deal with
  262. 8:39that. I just want all of my built
  263. 8:41binaries in one place because that's
  264. 8:43usually the typical case. You want them
  265. 8:45all there. So, they're going to be in my
  266. 8:47solution directory in a folder called
  267. 8:48bin, which stands for binaries, in the
  268. 8:50appropriate platform folder. So in our
  269. 8:52case really it'll only be win32 or x64
  270. 8:56and then inside a configuration. So
  271. 8:58either debug or release in our case. Now
  272. 9:00this last part putting it into a
  273. 9:02separate folder for each configuration.
  274. 9:04Again not something that I do all the
  275. 9:06time. Sometimes I just like to change
  276. 9:08the target name to maybe have debug
  277. 9:10appended to it for the debug build and
  278. 9:12potentially release or nothing at all
  279. 9:14appended to it for the release build.
  280. 9:16It's it varies honestly based on how I
  281. 9:19how I deal with my projects, but in this
  282. 9:20case, I'm just going to put them into a
  283. 9:22separate folder. Now, intermediate
  284. 9:24directories are going to be very
  285. 9:25similar. I'm going to put I'm going to
  286. 9:27I'm just going to copy everything from
  287. 9:29the output directory, put it into the
  288. 9:30intermediate directory. The only
  289. 9:32difference is that inside bin, I'm going
  290. 9:34to make a folder called intermediates
  291. 9:38and then put them there by platform, by
  292. 9:40configuration. Again, sometimes I put
  293. 9:42this intermediates folder at the very
  294. 9:43end so that it's already inside
  295. 9:44everything. But this way, it's just a
  296. 9:46little bit cleaner for you to be able to
  297. 9:47copy, say, the platform that you want
  298. 9:49and only have all the built binaries, no
  299. 9:51intermediate files. So, if I now hit
  300. 9:53okay, right, we can clean our project,
  301. 9:55which should get rid of a lot of the
  302. 9:57previous files. If not, cuz it never
  303. 9:59really does work that well. I like to go
  304. 10:00into the file explorer and just delete
  305. 10:02all of these files that I don't care
  306. 10:04about. So, all the debug directory. You
  307. 10:06can see that now I'll even delete this
  308. 10:07bin directory. You can see that now all
  309. 10:09we have is a solution file, the project,
  310. 10:12we've got the project filters and a user
  311. 10:13file which is just basically our current
  312. 10:15Visual Studio configuration. And then in
  313. 10:17source we've got main. So it's nice and
  314. 10:18clean. I'm going to go back to Visual
  315. 10:19Studio and I'm going to build. All
  316. 10:22right, cool. So if we go back here and
  317. 10:24we go to bin, we can see we've got
  318. 10:26intermediates and then Win32. So inside
  319. 10:28intermediates, we've got Win32 debug.
  320. 10:30That's all of our intermediate files
  321. 10:31such as our OBJ files. And then if we go
  322. 10:34back, you can see we've got win32 debug
  323. 10:36and then that is our exe file and we can
  324. 10:38run that and everything's fine. All
  325. 10:40right, cool. One little thing as well.
  326. 10:41You can see that we've got a double
  327. 10:42backslash here because of course I did
  328. 10:45forget that the solution directory,
  329. 10:46anything that has like project directory
  330. 10:48or solution directory actually has a
  331. 10:50backslash on it already because it's a
  332. 10:52directory name. So we can just go back
  333. 10:54and fix that up so that we don't get the
  334. 10:56double backslash. If you're not sure
  335. 10:57what one of these macros is equal to or
  336. 11:00you would like to see what it is, you
  337. 11:02can just go under edit here and then we
  338. 11:04can expand this macros view. And then
  339. 11:07over here we've got everything we want.
  340. 11:08So for example, that solution directory
  341. 11:10that I was talking about, you can see
  342. 11:11it's cdev new project. And you can see
  343. 11:13it does in fact end with a backslash.
  344. 11:15All right, cool. So that's pretty much
  345. 11:16it. That's all I just wanted to say.
  346. 11:17Setting up your directories, really
  347. 11:19important, really quick tip that that
  348. 11:21will just kind of make your life easier
  349. 11:22as far as organization goes. These are
  350. 11:24the settings that I use all the time. We
  351. 11:27might talk about more or less the
  352. 11:28compiler settings and linking settings
  353. 11:30and all of those kind of maybe release
  354. 11:31mode optimization settings in another
  355. 11:33video. I just wanted to show you guys
  356. 11:35the basis of how I set up every new C++
  357. 11:37project that I do. If you guys enjoy
  358. 11:39this video, please hit that like button,
  359. 11:41follow me on Twitter and
  360. 11:43Instagram, and and I will see you guys
  361. 11:48in the next video. Goodbye.
  362. 11:50[Music]
  363. 11:59[Music]
  364. 12:01Hey, hey,
  365. 12:03[Music]
  366. 12:04hey, hey, hey.

About this transcript

This page contains the full transcript of BEST Visual Studio Setup for C++ Projects! by The Cherno, generated from the public captions YouTube serves with the video. The transcript has 2,605 words across 366 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.