Skip to content

Running Large-Scale C/C++ code on Macbook with M-Series chip

Notifications You must be signed in to change notification settings

Virtigox/C-Cplusplus-Setup-on-Mac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

C++ Setup on Mac

  • Running Large-Scale C/C++ code on a Macbook with an M-Series Chip
  1. 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.
  2. Install Xcode Command Line Tools

    • Open Terminal
    • Run the following command to install command line tools:
xcode-select --install
  1. 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)"
  1. 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
  1. Download and Install Visual Studio Code. If already skip this step.

  2. 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
  3. 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
      1. Open the command palette by pressing cmd+shift+p
      2. Find the CMake: Quick Start
      3. Enter the name of the project
      4. Choose c++ project option
      5. Choose c++ executableoption
      6. Not Mandatory : include other extension package
      7. Choose the .cppfiles
  4. Build and Run the program by selecting play button down the VSCode.

Pasted image 20240909153320
  1. 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
{
    "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"
}
  1. 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.
Pasted image 20240909153320

About

Running Large-Scale C/C++ code on Macbook with M-Series chip

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published