MSYS2 - Install C/C++ Compiler Tools on Windows PC (EASILY)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today I'll be showing you how to install the new compiler tools for C and C++ this tool chain comes with most of the tools that you need in order to get started to compile projects in C and C++ on Windows to get started we want to go to the msys2 website I'll post a link in the description below where it says msys2 is a collection of tools and libraries providing you with easy to use environment for building installing and running native Windows software it includes upto-date native builds for GCC mingw cpython cmake Mason op SSL ffmpeg Russ Ruby and many more to download and install it's pretty easy to download just click the download the installer button here and that will launch a download for the executable application hit save somewhere on your computer and let's go find that download all right the download here has finished downloading into my download folder where I'm going to launch it from by double clicking and next I'm welcome to the msys 2 setup first off I'll hit next to start the installation it's asking us where we want to actually install our tools so make sure you put it somewhere that you'll remember on your system C ms64 is fine by me I'm going to hit next following that it's asking for what you want to call the shortcut so you can get it from your program shortcut says enter a name to create a new directory I'm just going to stay with the default you can call it whatever you want that makes sense to you hit next and let it install and unpack its components it'll take a little while if you want to see the details you can hit show details so you can follow along with what it's doing currently it's extracting and now installing the system tools all right once the installation's finished it'll say all components installed and we're ready to hit next and then you'll get a checkbox to run MSY 2 right away I'm going to allow that to be selected and hit finish what then will happen is you'll get a launched terminal this is msys 2 so in here you can use it like you would use a Linux environment so for example if I wanted to list something i' do LS if I wanted to clear things out I do clear let me make things bigger so we can see a little better basically this is a bash shell look at that if I type in VI it says bash command not found so what's nice about this is it actually gives us a package manager to use in this shell which is Fant fantastic for those of you who've used Archer Linux in the past you'll Rejoice because you can now use Pac-Man to install some of your favorite system build tools including the base development package which will help you get tools directly onto this Windows computer anyways I'm going to do Pac-Man DS first thing I'm going to get is vim so I can actually read in files and it says do I want to proceed with this installation well yes enter it's going to retrieve some packages that way I can write a simple program now I can open and create files on here if you need to see where you're currently located just type in PWD or in I'm in Home Savvy currently and now let's actually install some build tools for most build tools here with Pac-Man we can do Pac-Man DS and do the base-devel package this will install quite a few utilities for us including things like make and autom make GDB and a few others here notice all the pack packages that we get fantastic so can we use GCC nope g++ nope so the next one we want is going to be Pac-Man space- s and we want the GCC and probably cake packages let's enter those both in and press enter to get things going this is the Fantastic thing about using msis 2 it makes it really easy to get packages with a Linux package manager that you would be using in Linux directly on your Windows computer and I'll actually show you how to integrate this whole thing inside of windows so you can use it from the windows terminal Powershell or command prompt but now let's check if we finally have g++ for our C++ programs this is great it says no input files what about GCC for our C files for our C compilation absolutely here great if you ever want to check the version you can do g++ I think it's Dash version and there we go 11.3 is the current version of that uh you can check GCC I believe the same way to two dashes with the version and that one's also at 11.3 of course they got installed together so that's what you would expect you can also install the likes of python if you want whatever your heart desires at this point so interestingly enough you might be asking how do I reach folders on my Windows computer if I'm using this this bash shell environment well you can actually do CD for change directory do slash that's going to take you to the root directory and you can see here we have a few things available to us if you want to change directories you can do CD for example maybe I want to access the C drive well I can do C slash and then from there if I tab I have access to my croot directory fantastic now I can access things like my user home directory and even things like downloads where I just got done downloading a file why do I say this well you can compile things directly in here for example let me create a new text document and a C++ program so we can give this a shot so in order to make my first hello world program I'm going to include the io stream library and do int main for my main function call out the standard library and print out hello world I'm also going to put an endline here and then finally return zero at the end and that should be enough to get things going here I'm going to save this as main.cpp after I'm done saving that I have this main.cpp file in my downloads folder fer so how do I compile that well I can use the fact that I can navigate my windows directories and just do g++ and specify the location of that main CPP file and then I'm going to Output it I'll just output it directly here so I'm just going to call it Main and press enter all right things compiled it didn't complain to us and look at that if I do LS I see main.exe located in the current directory which is my Home Savvy directory fantastic let me see if I can run this real quick I'm going to do/ main.exe look at that hello world was successfully spit out at me meaning it successfully ran directly from my c 2 this bash shell here fantastic work but now let's make this work in a terminal so start up a terminal and then try g++ it's not going to work because the system can't find this tool yet but we can help it find it so what we will want to do first search for environment en M or environment variables and make sure to find something that says edit the system environment variables in the control panel click on this and you should see this environmental variables button which will then show you the environmental variables go down to path and hit edit and then let's add in a new location by default in the C my CIS 64 user bin directory is where we'll find the g++ tool so we're going to copy and paste that location directly in to a new location for the environmental variable after that's done we should be able to hit okay make sure you also hit okay on this one as well so so things apply and then hit okay on this one as well now you'll try g++ and it won't work again because you need to restart the terminal I'm exiting out and then I'm starting a new one okay now let's try g++ look at that this time it says fatal error no input files well I'm just going to transfer over to the downloads folder and inside here here I'm going to list things out and notice I still have that main CPP file well this time I'm going to do g++ main.cpp and I'm going to Output it as main things compiled it didn't complain I'm going to list the contents now now I have main executable in my downloads and I'm going to try running that main executable real quick main.exe and look at that hello world now you have it working across the system as well in your native Windows terminal Powershell and command prompt congratulations you've now made a cohesive experience for yourself to develop C and C++ programs if you'd like me to talk about how to set up python with this same tool let me know in the comments section below and know a lot of you asked for this one using msys 2 catch me in a great community on Discord and I'll catch you in another video thanks for watching Linux can be hard to understand but I take the most commonly used terms commands and subjects in Linux and I break them down into simple to read documents including Linux terms flashcards a checklist a cheat sheet and a mind map and if you're ready to level up your Linux experience and knowledge go to learn. saavy nick.com now and get access to these sheets
Info
Channel: SavvyNik
Views: 2,644
Rating: undefined out of 5
Keywords: gcc, g++, c++ compiler, savvynik, open source, gcc compiler, gcc compiler windows 10, how to install gcc compiler in windows 10, install gcc compiler windows 10, how to install gcc, c compiler for windows 10, gcc install windows 10, mingw, install gcc, gcc tutorial, gcc windows, how to install gcc compiler in windows 11, c compiler for windows 11, gcc install windows 11, install gcc compiler windows 11, msys2, pacman, arch linux, package manager
Id: pTtF6TKJpo8
Channel Id: undefined
Length: 9min 16sec (556 seconds)
Published: Mon Oct 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.