0% found this document useful (0 votes)
38 views20 pages

"Hello World!": Setting Up C++ Environment

This document provides instructions for setting up a C++ development environment on Ubuntu/Linux, Windows, and Mac OS using Sublime Text as the code editor and g++ as the compiler. It explains how to install Sublime Text and g++, configure the environment, and provides steps to write and run a simple "Hello World" program to test the setup.

Uploaded by

Manikya Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views20 pages

"Hello World!": Setting Up C++ Environment

This document provides instructions for setting up a C++ development environment on Ubuntu/Linux, Windows, and Mac OS using Sublime Text as the code editor and g++ as the compiler. It explains how to install Sublime Text and g++, configure the environment, and provides steps to write and run a simple "Hello World" program to test the setup.

Uploaded by

Manikya Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Setting up C++ Environment

Sublime Text Installation and G++ Compiler Set Up

“Hello World!”
I’m here to help you to get started with your programming journey! :)

Now for executing a program, you need an editor (for writing code) and a compiler (for
translating the source code into machine understandable format)

For our purpose we’ll using:

1) Sublime Text​ as editor (it is easy to use, compatible with all languages and it’s system
requirements are minimal).

2) g++ as ​Compiler.
Installation
Ubuntu/Linux

g++ Installation​:
1) sudo apt-get install g++

Sublime Installation:
You can refer sublime text website ​https://www.sublimetext.com/​ to install sublime text
editor or install via command line using the following steps.

1) Open terminal via Ctrl+Alt+t or by searching for “Terminal” from desktop app launcher.
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo
apt-key add -

2) echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee


/etc/apt/sources.list.d/sublime-text.list

3) sudo apt-get update

4) sudo apt-get install sublime-text

Testing:
1) Open sublime text and save file with the format filename.cpp.
2) Now let’s write a simple C++ code.
3) Open terminal via Ctrl+Alt+t or by searching for “Terminal” from desktop app launcher,
and direct to the directory where the cpp file is located.

4) Now to build the souce code, type this command in the terminal
g++ filename.cpp -o run

5) Now to execute the file, type the command : ​./run


Windows

Sublime Installation:
1) Go to ​cb.lk/editor​ to download sublime text setup for windows and install it.

g++ Installation​:
1) Go to cb.lk/compile to download minGW.zip
2) Go to downloads and extract all the components of minGW.zip
3) While extracting the component of minGW.zip set location as C:
4) Once the folder is extracted, go to C:\MinGW\bin and copy the path
5) Now go to This PC and right click and click on properties

6) Click on Advanced system settings and a window of System Properties will open.
7) Now go to Environment Variable and under System variables, double click on path
8) Now click on new to add a new path
9) Paste the C:\MinGW\bin in the new path

10) g++ is installed.

11) Now let’s integrate sublime with g++.

12) Now open sublime and go to Tools and select Install Package Control…
13) Wait for a few seconds, a pop will come up stating that Package Control is installed.
14) Now go to preferences and select Package Control, after selecting a search window will
pop up. Search for the keyword “install” and select the first option that is, Install Package
and then wait for a few seconds.
15) Once the Package is installed another search bar will appear and now search for the
keyword “terminal” and select the first option that is, Terminal.

That’s it, sublime text is now integrated to g++ compiler.

Testing:

Now let’s test our installation by running a simple Hello World code on C++.

1) First save the empty sublime text editor on system with -> filename.cpp.
Here cpp specifies that it is a C++ file.
2) Now let’s write a simple C++ code.
3) Once you are done writing code, press Ctrl+B, there will be 2 options C++ Single File
and C++ Single FIle-Run. Select C++ Single File. This will build the file and also detect
are their any error or not.

4) Now that your program is built, for it’s execution open PowerShell using Ctrl+Shift+t.
5) For executing code type, .\filename.exe and press enter
For example in our case, ​.\helloWorld.exe

Mac OS

Sublime Installation:

1) Go to ​cb.lk/editor​ to download sublime text setup for windows and install it.

g++ Installation:

1) Open terminal and run the command:


xcode-select --install

Testing:
1) Open sublime text and save file with the format filename.cpp.
2) Now let’s write a simple C++ code.
3) Open terminal and direct to the directory where the cpp file is located.

4) Now to build the souce code, type this command in the terminal
g++ filename.cpp -o run
5) Now to execute the file, type the command : ​./run

That’s all for sublime text and g++.

If anyone wants to use some other IDEs then Code::Blocks, Clion and Atom.

Atom is quite similar to Sublime Text. In my experience Clion is really beneficial for beginners

but it’s paid, you can apply for 1 year student subscription which is completely free. :)
Happy Coding!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy