- Running Large-Scale C/C++ code on a Macbook with an M-Series Chip
-
Install Xcode
- Open the App Store and search for Xcode.
- Install the latest version of Xcode.
- Type
xcode-select --version
to check whether it's already installed.
-
Install Xcode Command Line Tools
- Open Terminal
- Run the following command to install command line tools:
xcode-select --install
- Install Homebrew
- Open Terminal and and install Homebrew by running:
- Type
brew --version
to check whether it's installed.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install CMake via Homebrew
- Install Cmake(for building C/C++ projects) using Homebrew:
- Type
cmake --version
to check whether it's installed.
brew install cmake
-
Download and Install Visual Studio Code. If already skip this step.
-
Install necessary VS Code extensions:
- Open VS Code
- Press
cmd + shift + X
to open the Extension view. - Search for and install the following extensions:
- CMake Tools
- C/C++ by Microsoft
-
Set up your project
- Create a new folder for your project
- Enter the project where your executable programs exist
- Add your source files and CMakeLists.txt
- Open the command palette by pressing
cmd+shift+p
- Find the
CMake: Quick Start
- Enter the name of the project
- Choose
c++ project
option - Choose
c++ executable
option - Not Mandatory : include other extension package
- Choose the
.cpp
files
- Open the command palette by pressing
-
Build and Run the program by selecting
play button
down the VSCode.
![Pasted image 20240909153320](https://private-user-images.githubusercontent.com/70658351/366037996-acc3c506-2023-4432-b15d-db2627bf412e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTc1NzYsIm5iZiI6MTczOTM1NzI3NiwicGF0aCI6Ii83MDY1ODM1MS8zNjYwMzc5OTYtYWNjM2M1MDYtMjAyMy00NDMyLWIxNWQtZGIyNjI3YmY0MTJlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDEwNDc1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFkOTM2ZTA1YmU2NDY0ZmM0MDM0YjViMmIwYzJhM2RlN2M2NTBhMjAwOGJjNjc0YjdiYjQ2YTFjNTc0NjhkY2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.xUQFMDpJ7W9gaMP8MtYi4uL5pFrQR4bnMEzZ8nP3mi0)
- Configure Debugging
- To debug the C++ program using LLDB, set up the launch.json configuration. Open your
launch.json
file and add the following configuration for debugging: - Read this in VScode_web
- To debug the C++ program using LLDB, set up the launch.json configuration. Open your
{
"configurations": [
{
"name": "C/C++: clang++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ build active file"
},
{
"name": "C/C++: clang build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang build active file"
}
],
"version": "2.0.0"
}
- Final step is to choose a kits which a toolchain for compiling and linking the project.
- Choose the kit in
No Kit Selected
section. - Or goes to the command palette, and select toolkit from
CMake: Select a kit
option. - Select the appropriate one and Happy Coding.
- Choose the kit in
![Pasted image 20240909153320](https://private-user-images.githubusercontent.com/70658351/366038220-f95c71ba-1985-4fad-b8d3-87a68675f10e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTc1NzYsIm5iZiI6MTczOTM1NzI3NiwicGF0aCI6Ii83MDY1ODM1MS8zNjYwMzgyMjAtZjk1YzcxYmEtMTk4NS00ZmFkLWI4ZDMtODdhNjg2NzVmMTBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDEwNDc1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEwMjcxMzFlOThiMzI2NGQzNjZhOGFhNGJhZjY1MGFhNjAyMWJlZTRjYzU2ZmQxYjBjNTBkMjllMThkMjRkYjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.J3Fy1SlCHpxRhZL8fRVamfga9dmW__H-UrOJl8O5t7o)