How to setup C++ on Linux | easy and epic explanation 2021

setup C++ on Linux

Today you’re going to setup C++ on Linux. Okay cool let’s cover how we can set up the tools we need on Linux so that we can make staples plus program now of course there are so many different tools out there so many different ways to write and build your card I’m going to cover one of those ways one that I personally like I hope you’re ready to do some serious setting up I mean you’ve chosen Lennox are obviously you’re going to be prepared to do some live basically we’re going to use Cake to generate project files for an ID a cold card light car light is a nice light white ID that basically does pretty much everything you would expect but isn’t too heavy weight and just lets us right out card in a nice way so let’s go ahead and set everything up so we’ve got a virtual box VM here running mint 18.one an amusing Katie is my G. U. Y. so if I go ahead and open a terminal we can get started the best thing I like to do is set up a directory yeah hold Dev which is basically going to hold the about development stuff will make and then. setup C++ on Linux setup C++ on Linux

Basically inside here will have a like a folder for each project so I’ll make a directory hello world which is going to be what we’re going to do you know what I set up a base closure will project now tens of the applications that we actually have to install we basically need the one that we really need a compiler the same make and collide so the first thing you’re going to want to do it with all that is to suit our apt get update that’s just going to basically updating your root password that’s going to basically update all about package packages a package repositories and then once that’s done we can actually install the packages we need sorry what we need are will do after that. Installed I like to use them as my terminal text editor and then we’ll get your post last while I look at cars lights as ID and we will get same make and then just had asthma risk save like 190 megabytes why this will take a while okay so once that is done let’s go ahead and clear this Sir we’ve got nothing in that directory right now I like to make a directory called source and that’s real actually pulled my source files. setup C++ on Linux setup C++ on Linux

I’m going to just create a file in the source directory called main does he pay I’m just not Mariah anything into it I’m just going to create the empty file intellectually that could light had let fall for us we’re going to need to set up a C. make file and then I also like to set up a build scripts of the week on easy way to generate project sometimes the same make that fast I’m sneeze van you can use any tests that are the like the file is going to be cold C. make lists. Taxed and is going to basically just instructs they make how we want to actually generate alkali project file server. Festival will specify minimum version of say make that we made as a good rule of thumb I like to just roll with version 3.5. Well then give a project name stockholders hello world. And then we’ll set up some variables essentially say I intensive like flags that we want to use for compilation loonies the existing ones so that’s.  setup C++ on Linux setup C++ on Linux

Basically beat makes excessive lags. Which other compilation flags but it is what we actually want to do we want to add up we wanted to spoil warnings errors of course and then intensive like which standard library use you can use people’s levels of 140 doesn’t really it doesn’t really matter for this project since we’ll be just using will be printing hello world but with all the 14 this feature for fans of the little bit. Lucrative variable Hackle source directory and actually set this to be the project full stricter. And then. Sensually just the follicle sauce so the parcels directory is the director of currently in an inside that I’m just making obvious metrical sauce in a small muscles falls off so that worked out pretty well Sir we set up these variables right those 2 lines are just variables we set out flags we set ourselves directory. Now we actually need to somehow tell the compiler which files to compile sorry again raising Cake we can just use it a lot for that so basically I’m going to specify the muscles files are going to be in that source directory and SO structures is this terrible death made up here right and then basically anything inside that directory that and C. ++ and sipping I want to compile nephew had include directories and stuff you would also want to set that up but for now we’re not going to do that was at X. cuticles there’s going to be a target hello world that project name and then which files you want to call things as they are going to be our schools files if you had to get in the director is something you would also positive but there. setup C++ on Linux setup C++ on Linux

We go that’s all about stuff that’s our high C. make lists done so that’s right and quit now set up a script that will run Cake forests are all coldest builds’. H. now this is really going to build out card it’s just going to generate the project and all straight kind of how this works in a minute but basically the first thing we want to do is make sure that batch is going to be able to ask and all that so I will add. S. H. as every batch script will have. Then we’ll do the same make – J. so it does the target we’re going to be using provide light Unix make files don’t see something like ninja if you live. Probably a bit better this is just basically set up and then. As far as my bill type goes I’m actually going to set that’s a bug my C. setup C++ on Linux setup C++ on Linux

Michael type because Jernigan data configuration for what we want anyway since we’ll be talking a lot and you want to make sure the cut line as a capital L. here and that’s it we can write and quit that and that’s how it’s coming on tile script very simple so now we’re ready to run out script now in order to run a script in Lennox you have to market is that as executables will just 3 C. H. mauled. Plus acts and then build S. H. so is adding the extra flags to the bills to S. H. file now we can run its. Interface he did everything correctly you can see that it’s written some build files for us so if we look at the directory this is a number of new files here the ones that we can care about off label to project leveled off work spaces there make files as well that. You can see that those kind of the phones so now how do we open the sim card light well I like chip which is evident through the terminal so you can just type in car lights and then hello world web space now if you want to open in the background so you can still use your terminal just an absent on fans and stuff and could light should open now you probably don’t want to run through the setup of the castle cancel you can see we got our project yet out target.  setup C++ on Linux setup C++ on Linux

This means a bit bigger we’ve got our include directories of his ballot R. includes cart sauce is going on here with a look at fault Arpanet I’m going to just basically type out a simple hello world application so we’ll say. And we’ll do a little. C. N. get as well all right save that you want to build it you can just hit build and build projects. Outputs down here and you can see the everything’s fine there errors or warnings we’re ready to go. To go back to terminal. And I do an LS you can see we’ve got a hello world our filings actually setup C++ on Linux setup C++ on Linux executable. Right says actual program so let’s go ahead run that they get a hello world. We’ve written our first application if you want to run inside here one thing I like to do is just go to preferences and make use that built and terminal emulator and then you can just do build run we can build and execute it and you can see here it is running inside of. I live. All right that’s it Lennox is set out where interesting car were ready to learn some C. ++

Also See

What are Dynamic Arrays in C++ Part 2 | Top and Latest 2021

Leave a Comment

Your email address will not be published. Required fields are marked *