diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 91a7b5a84d10e1..5756aaa35b7e26 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -235,3 +235,7 @@ void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint) WakeOnLan::SetDefaultDelegate(endpoint, &wakeOnLanManager); } #endif + +// No-op function, used to force linking this file, +// instead of the weak functions from other files +extern "C" void chef_include_stubs_impl(void) {} diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt index 75cf0b85222d95..549f98abcfac9c 100644 --- a/examples/chef/esp32/main/CMakeLists.txt +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -121,6 +121,9 @@ idf_component_register(PRIV_INCLUDE_DIRS PRIV_REQUIRES chip nvs_flash bt console mbedtls QRCode tft screen-framework spidriver SRC_DIRS ${SRC_DIRS_LIST}) +# Forces the linker to include common/stubs.cpp +target_link_libraries(${COMPONENT_LIB} INTERFACE "-u chef_include_stubs_impl") + include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") chip_app_component_codegen("${CHEF}/devices/${SAMPLE_NAME}.matter") chip_app_component_zapgen("${CHEF}/devices/${SAMPLE_NAME}.zap")