3.0 Install Visual Code

Start by downloading VS Code.

Then install it and then install the CMake and C++ plugins.

This can be done accessing the extensions’ menu button on the left. cmake_tools cpp_tools

It will take a while, but it will locate the available toolchains for you to use.

3.1 Configuring ns-3 with Visual Code

It is literally just opening the ns-3-dev folder. It will run CMake automatically. open_project

After that, you can choose ns-3 features opening the CMake cache and toggling them on or off. open_cmake_cache configure_ns3

I’m going to enable examples now. enable_examples_and_save_to_reload_cache

Boom. Just like that cmake will run and update the targets on the left side of the screen in the CMake menu.

3.2 Building the project with VS Code

We can now select which target we want to build/debug on the left side menu. I’m going to pick a random example and click to debug it. It will be built and debugging will start right after that. select_target_build_and_debug

While we wait for the compilation, lets appreciate the macro expansion feature.

macro_expansion

3.3 Running executables with VS Code

Select the target, right-click to choose to run or debug, like in the previous section.

After that, we can open the source file, put a few breakpoints and debug.

happy_debugging

Video covering all steps