Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

CPP-MacOS-VSCode-Template

A macOS-specific C++ setup for VS Code, including zsh tips, SDKROOT handling, and build tasks for the freeCodeCamp C++ Programming Course.

Struggled with the setup for days? Been there, done that — here’s the result, which hopefully helps you get past this first obstacle.

⚠️ This template is intentionally macOS-specific. Windows users should follow the original freeCodeCamp setup.

⚠️ Note: This template works on my machine, but due to differences in VS Code settings.json or environment setups, it might not run out-of-the-box on yours. If you run into issues, feel free to open an issue or contact me — I’ll do my best to help.

On macOS, there are a few differences compared to Windows/PowerShell in the shell commands and the build process. After installing all the compiler-related tools via Homebrew:


1. Shell & File Listing

macOS uses zsh, not PowerShell:

  • Commands like dir do not exist.

  • To list files and directories (including hidden ones) in the workspace:

    ls -lhA
  • Optional alias to mimic PowerShell dir per session:

    alias dir='ls -lhA'

2. Binary Naming & Running

macOS builds differ from Windows:

Shell / OS Binary Type How to Run
zsh / macOS Standard build task binary (e.g., rooster) ./rooster
zsh / macOS Per-file build binary (e.g., ${fileBasenameNoExtension}) ./<filename>
  • macOS does not produce .exe files.
  • Always prepend ./ to run a binary in the current directory.

3. Compiler & Toolchain

  • Xcode Command Line Tools must be installed:

    xcode-select --install
  • VS Code build tasks (.vscode/tasks.json) handle compilation automatically; you do not need to type compiler commands, but might want to change pats or naming of the created build to your liking.

  • Alternative compilers (Homebrew LLVM/clang, GNU g++) can be used in tasks.

  • For Homebrew Clang, -isysroot ${SDKROOT} ensures SDK headers are found; Apple Clang and g++ generally do not require it.


4. SDKROOT Notes

  • Apple Clang: usually no -isysroot needed.
  • Homebrew LLVM/clang: -isysroot ${SDKROOT} recommended.
  • GNU g++: ignores -isysroot unless explicitly configured.

5. Typical VS Code Workflow

  1. Use the build task (per-file or full project).

  2. Executable appears in workspace folder.

  3. Run in zsh:

    ./<binary-name>
  4. List workspace contents:

    ls -lhA

Summary

Concept macOS Behavior
Shell zsh (not PowerShell)
Listing files ls -lhA or dir alias
Binary name Standard: program / Per-file: <filename>
Running programs ./binary-name
Compiler Handled automatically by VS Code build tasks
SDKROOT Used only for Homebrew Clang; Apple Clang / g++ usually not required

About

A starter-template to follow the freeCodeCamp C++ course on MacOs using VSCode.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages