Portrait of me in my natural habitat

How to Fix Build Errors with Chip Tool

Posted 2023-07-28

make sure you run git submodule update --init inside the matter folder

When setting up the chip tool for testing matter devices on macOS, you might run into issues with the build command

./scripts/examples/gn_build_example.sh examples/chip-tool BUILD_PATH

For me, it reported a bunch of errors like these:

...

The target:
  //third_party/connectedhomeip/third_party/libwebsockets:libwebsockets
has a source file:
  //third_party/connectedhomeip/third_party/libwebsockets/repo/lib/system/system.c
which was not found.
___________________
ERROR at //third_party/connectedhomeip/third_party/libwebsockets/BUILD.gn:33:1: Source file not found.
source_set("libwebsockets") {
^----------------------------
The target:
  //third_party/connectedhomeip/third_party/libwebsockets:libwebsockets
has a source file:
  //third_party/connectedhomeip/third_party/libwebsockets/repo/lib/roles/ws/ops-ws.c
which was not found.
___________________
ERROR at //third_party/connectedhomeip/third_party/jsoncpp/BUILD.gn:26:1: Source file not found.
source_set("jsoncpp") {
^----------------------
The target:
  //third_party/connectedhomeip/third_party/jsoncpp:jsoncpp
has a source file:
  //third_party/connectedhomeip/third_party/jsoncpp/repo/include/json/allocator.h
which was not found.
___________________
ERROR at //third_party/connectedhomeip/third_party/editline/BUILD.gn:30:1: Source file not found.
static_library("editline") {
^---------------------------

The first step in Building the CHIP Tool says

Install all required packages for Matter and prepare the source code and the build system. Read the Building Matter guide for instructions.

I think incorreclty assumed that was completed when setting up the nRF SDK. You should have the Matter repository installed under /modules/lib/matter, but you still have to run git submodule update --init in that directory.