Share on facebook
Share on twitter
Share on pinterest

In this section of the C++ tutorial, we will have a look at the C++ environment setup on the different operating systems.

C++ Environment Setup

C++ programs can be executed on a different operating system like Windows, Mac, and Linux, etc. Each operating system has its own procedures to set up the C++ environment. Let’s have a look at how to set up the C++ environment on different operating systems one by one.

C++ Environment Setup on Windows

There are a lot of IDEs available for Windows operating system that you can use to work easily with the C++ programming language. Borland Turbo C++  is one of the most popular IDEs. To download it, you may want to visit this page. Once you have downloaded File from the link, open it and follow the installation instructions.

  • After successfully installing Turbo C++, go to File menu -> Select New and create an Empty file.
  • Now write your C++ program in this empty file and save the file with a ‘.cpp’ extension.
  • After saving the file with ‘.cpp’ extension, go to the ‘Run’ option available on the top menu & play with your code.

C++ Environment Setup on Mac

You need to download Xcode if you are a Mac user. You need to visit the Apple website to access Xcode, or you can check it in the apple app store. You may use to download the Xcode. Here you will find all the required installation instructions.

  • After Xcode has been successfully installed, open the Xcode application.
    Create a new project. Go to File-> Select New-> Select Plan. This is going to create a new idea for you.
  • Now you have to choose a model for your project in the next tab. To choose a C++ model, choose the Program option in the OS X section of the left sidebar. Now choose the command-line tools from the options available and click the Next button.
  • In the next window, provide all the necessary details, such as’ organization name,” product name,’ etc. Yet make sure you choose the language like C++. After filling in the details, click the next button to proceed to the next steps.
  • Choose the location where you want your project to be saved. After this, choose the main.cpp file from the directory list on the left side of the bar.
  • Now, after opening the main.CPP file, you will see a pre-written c++ program or template provided. You may want to change this software as per your requirements. To run your C++ program, you need to go to the Product menu and choose Run from the drop-down menu.

C++ Environment Setup on Linux

If you are a Linux user, you can use the GNU GCC compiler. You have to follow the below-mentioned steps to getting started with C++.

  • Run the below-mentioned code to install the GNU GCC compiler on your Linux terminal.
sudo apt-get update
sudo apt-get install GCC
  •  To install the essential libraries, you have to run this code.
sudo apt-get install build-essential
  • To ensure it’s installed correctly on your system, run the below-mentioned code on your terminal.
g++ --version
  • If the above two steps have been completed error-free, your Linux environment is developed and ready for compiling C++ programs. In the next steps, we will learn how to compile and run a C++ program on Linux using the GCC compiler.
  • Write the code to a text file and save it with any file name and. CPP extension. We’ve written a program to display “Hello World” and saved it to a file named “firstcode.cpp” on the desktop.
  • You now have to open the Linux terminal and move to your file saved directory. So you have to run the following command to compile your file:
g++ filename.cpp-o any-name
  • Now, you have to execute the command below to run your program:
g++ firstcode.cpp -o hello

Subscribe to our Newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

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