Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (2024)

Xcode is an IDE developed by Apple themselves to develop apps for macOS and iOS or all other Operating Systems that Apple develops. It also has support for C/C++ built-in. Here, finding a C++ IDE for a macOS system is quite easy. To run a program in C++ in Mac we have to install Xcode or command-line tools for Xcode.

Ways:

Hence, there are two options to run a C++ program on Mac.

  1. Download and install from Apple Appstore
  2. Download and install by using Command Line Tools and using any preferred IDE or Code Editor for writing C or C++ code.

Way 1: Download and install from Apple Appstore

Note: The macOS version of Visual Studio is not available for C or C++ as we can develop C# but not C/C++.

Procedure:

Step 1: Install Xcode software on the machine on which programs are to be written. So after downloading the Xcode application and later on opening it, you will be greeted by the pop-up as shown below

Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (1)

Step 1.

Step 2: Now click on the link “Create a new Xcode project”.

Step 3: Again, if there is an existing project you will click on “Open a project or file” or “Clone an existing project” if the project is on source control.

Step 4: Click on the macOS tab and then click on the Command-Line app as it the only thing where we can develop apps in C and C++.

Step 5: It will now show an interface to give the product or the app a name and the package name as a normal IDE after giving that name there would be a drop-down to select a language. So, instead of swift, you can select C or C++ and click on the Next button.

Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (3)

Step 3.

Step 6: Then it will ask for the location of the project on your machine, and, done!, you can open or create a C or C++ file now.

Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (4)

Way 2: Installing the Xcode Command Line Tools and using any preferred IDE

In this method, we need to use the Terminal as we need to download and install only some part of Xcode and not the entire Xcode. This method is useful if you have limited storage or for some other reason. We will be downloading the 2GB part of Xcode rather than the entire 28GB Xcode as we only need the C and C++ compiler.

Procedure:

Follow the below step to set up the running environment for C++

Step 1: Open Terminal and type or copy and paste this command “xcode-select –install” and now Xcode Command Line Tools would be installing you will get an interface like this:

xcode-select --install

Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (5)

Step 2: Now click on Install it will ask for your device password so after entering the password it will install Xcode Command Line Tools. Now we can create a C or C++ file and edit it.

Step 3: Now use VScode or be it else of your choice as it is the best free code and install two extensions for C++.

Note: The first one is C/C++ official extension and the second one is Code runner

Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (6)

C/C++ extension

Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (7)

Code Runner extension

Now a C /C++ code can be run in VScode.

Master Software Testing and Automation in an efficient and time-bound manner by mentors with real-time industry experience. Join our Software Automation Course and embark on an exciting journey, mastering the skill set with ease!
What We Offer:

  • Comprehensive Software Automation program
  • Expert Guidance for Efficient Learning
  • Hands-on Experience with Real-world Projects
  • Proven Track Record with 10,000+ Successful Geeks

Last Updated : 23 Mar, 2021

Like Article

Save Article

Share your thoughts in the comments

Please Login to comment...

Different Ways to Setting Up Environment For C++ Programming in Mac - GeeksforGeeks (2024)
Top Articles
Latest Posts
Article information

Author: Jonah Leffler

Last Updated:

Views: 5822

Rating: 4.4 / 5 (45 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Jonah Leffler

Birthday: 1997-10-27

Address: 8987 Kieth Ports, Luettgenland, CT 54657-9808

Phone: +2611128251586

Job: Mining Supervisor

Hobby: Worldbuilding, Electronics, Amateur radio, Skiing, Cycling, Jogging, Taxidermy

Introduction: My name is Jonah Leffler, I am a determined, faithful, outstanding, inexpensive, cheerful, determined, smiling person who loves writing and wants to share my knowledge and understanding with you.