Skip to content

Instantly share code, notes, and snippets.

@PramithaMJ
Created March 14, 2025 17:30
Show Gist options
  • Select an option

  • Save PramithaMJ/5bf37d8b6e6c312265a80b1f76971df2 to your computer and use it in GitHub Desktop.

Select an option

Save PramithaMJ/5bf37d8b6e6c312265a80b1f76971df2 to your computer and use it in GitHub Desktop.
NS-3 Configuration Error on macOS

NS-3 Configuration Error on macOS

Error Message

❯ ./ns3 build
You need to configure ns-3 first: try ./ns3 configure
❯ ./ns3 configure --build-profile=debug --enable-examples --enable-tests
CMake Error: Could not create named generator Visual Studio 17 2022

Generators
* Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  Ninja Multi-Config           = Generates build-<Config>.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  Xcode                        = Generate Xcode project files.
  CodeBlocks - Ninja           = Generates CodeBlocks project files (deprecated).
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files (deprecated).
  CodeLite - Ninja             = Generates CodeLite project files (deprecated).
  CodeLite - Unix Makefiles    = Generates CodeLite project files (deprecated).
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files (deprecated).
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files (deprecated).
  Kate - Ninja                 = Generates Kate project files (deprecated).
  Kate - Ninja Multi-Config    = Generates Kate project files (deprecated).
  Kate - Unix Makefiles        = Generates Kate project files (deprecated).
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files (deprecated).
  Sublime Text 2 - Unix Makefiles = Generates Sublime Text 2 project files (deprecated).

Warn about uninitialized values.
Finished executing the following commands:
/opt/homebrew/bin/cmake -S /Users/pramithajayasooriya/Desktop/NS3-Azure DevOps/ns3-dev -B /Users/pramithajayasooriya/Desktop/NS3-Azure DevOps/ns3-dev/cmake-cache -DCMAKE_BUILD_TYPE=debug -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON -DNS3_NATIVE_OPTIMIZATIONS=OFF -DNS3_EXAMPLES=ON -DNS3_TESTS=ON -G Visual Studio 17 2022 -A x64 -T ClangCL --warn-uninitialized

Cause

The error occurs because Visual Studio 17 2022 is being used as a CMake generator, but it is not available on macOS. Instead, macOS supports generators like Unix Makefiles or Ninja.

Solution

Use Unix Makefiles or Ninja as the generator when configuring ns-3.

Steps to Fix

  1. Use Unix Makefiles:

    ./ns3 configure --build-profile=debug --enable-examples --enable-tests -G "Unix Makefiles"

    OR

  2. Use Ninja (recommended for performance):

    ./ns3 configure --build-profile=debug --enable-examples --enable-tests -G "Ninja"
  3. Ensure CMake and required dependencies are installed:

    brew install cmake ninja
  4. If using Apple Clang, set it explicitly:

    export CC=$(which clang)
    export CXX=$(which clang++)
  5. Clean and retry if needed:

    ./ns3 clean
    ./ns3 configure --build-profile=debug --enable-examples --enable-tests -G "Unix Makefiles"
    ./ns3 build

This should resolve the issue and allow you to build ns-3 successfully on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment