Since you want to use C++, you need the Visual Studio Build Tools compiler. Follow these steps:
-
Download Visual Studio Build Tools
- Go to: https://visualstudio.microsoft.com/visual-cpp-build-tools/
- Click "Download Build Tools"
-
Run the Installer
- Open the downloaded
.exefile - When prompted for workloads, select: "Desktop development with C++"
- Include these components:
- MSVC v143 or later
- Windows 10/11 SDK
- CMake tools
- Open the downloaded
-
Verify Installation
where cl.exe
You should see a path to the compiler.
-
Restart Your Terminal
- Close and reopen your terminal/VS Code
xcode-select --installsudo apt-get install build-essential python3After installing the C++ tools, run:
npm installThis will:
- Install all Node.js dependencies
- Build the C++ addon automatically (via
postinstall)
-
Install the C++ Extension
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "C++"
- Install "C/C++" by Microsoft
-
Select Configuration
- Open any
.cppfile in thecpp/folder - You'll see a popup to select a configuration (Win32/Linux/Mac)
- Choose based on your OS
- Open any
-
Verify IntelliSense
- Open
cpp/include/Process.h - Hover over types - you should see tooltips
- Ctrl+Click on includes - they should resolve
- Open
npm run build-nativenpm run devnpm run build- Make sure Visual Studio Build Tools is installed
- Restart Terminal/VS Code after installation
- Try:
npm config set msvs_version 2022
- Reload VS Code: Ctrl+R or Cmd+R
- Select the correct configuration in the C++ extension
- Delete
.vscode/settings.jsonIntelliSense cache
- Run:
npm run clean-native && npm install - Check build output:
npm run build-native -- --verbose
Your C++ code is organized as:
cpp/include/- Header files (Process.h, Algorithms.h)cpp/src/- Implementation filesbinding.cc- Node.js bindings*FirstServe.cpp- Algorithm implementations
The compiled addon will be available at:
build/Release/scheduling_algorithms.node(Windows/Linux/Mac)
Once everything is set up:
- Edit C++ files in
cpp/src/ - Run
npm run devto rebuild and test - Use VS Code debugging with the "Debug Development Server" configuration
- Changes will be hot-reloaded when you modify files
Happy coding with C++! 🚀