Open In App

C++ Installation on MacBook M1 for VS Code

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:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/  Homebrew/install/master/install.sh)"
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:

/usr/local/include

mkdir bits

nano stdc++.h
 {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.




#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.

Article Tags :