Skip to content
Related Articles

Related Articles

C++ Installation on MacBook M1 for VS Code
  • Difficulty Level : Easy
  • Last Updated : 12 Mar, 2021

This article is written on CPP installation for the latest  MacBook M1 processor. It’s not like we can’t do CPP programming in the latest MacBook, there is Xcode which is a substitute for other code editors. But still many of the developers like to code on Visual Studio.

So let’s start with this installation of CPP on Visual Studio code.

After downloading Visual Studio Code or Visual Studio Code Insiders open it and go to extensions. There is a search tab, just type c++ then click on 1 recommendation and install it. Another extension you have to download is code runner.

During this process, users can come across 2 different types of issues. So let’s discuss what they are and how to resolve them.

Problem 1: After downloading all extensions on VS Code not able to work on CPP.



Follow the below steps to resolve the same issue:

  • Step 1: Open your terminal and run the below command:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/  Homebrew/install/master/install.sh)"
  • Step 2: Now after the completion of the previous command type : 
arch -x86_64 brew install mingw-w64

Problem 2: #include<bits/stdc++.h> is not found .

If you want to more about the system header file click here. Follow the below steps to resolve the issue:

  • Step 1: Open terminal using command+space and type terminal.
  • Step 2: Now move to the below-given path :
/usr/local/include

  • Step 3: Now create bits directory in the present location
mkdir bits

  • Step 4: Now move into bits directory and create a file and name it  stdc++.h.
nano stdc++.h
  • Step 5: After creating a file just copy the code from the GitHub repository and paste that code into stdc++.h file and then press
 {control+x}-> y -> return

Now just try to implement any CPP code to ensure that you are done with the CPP setup on MacBook M1.

C++




#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    int a= 2, b=4;
    cout<<a+b<<endl;
    return 0;
}

That’s it. You have successfully installed CPP into your Mac M1.

Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up
Recommended Articles
Page :