❯ ./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
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.
Use Unix Makefiles or Ninja as the generator when configuring ns-3.
-
Use Unix Makefiles:
./ns3 configure --build-profile=debug --enable-examples --enable-tests -G "Unix Makefiles"OR
-
Use Ninja (recommended for performance):
./ns3 configure --build-profile=debug --enable-examples --enable-tests -G "Ninja" -
Ensure CMake and required dependencies are installed:
brew install cmake ninja
-
If using Apple Clang, set it explicitly:
export CC=$(which clang) export CXX=$(which clang++)
-
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.