Using FreeRTOS in own CMake project for ESP32 with AWS, problem with libraries linking

Hi,
I am trying to make a transition from provided demos to our own source code so we can test how things work with our software. In particular, I have went through Bluetooth OTA Update Example on AWS.

So nowbefore setting up my own project, I decided to try the amazon-freertos example with code from OTA MQTT BLE demo in order to create a starting point for adding other parts related to our code. I have looked through Getting started:Using FreeRTOS in your own CMake project for ESP32 with AWS and also checked some questions on the forum about CMake project setup issues with AWS FreeRTOS for ESP32. I was able to set up my cmake so I start building code, but I have problem when linking some libraries required for ble example, not sure how to add them. Here is my cmake file:

cmake_minimum_required(VERSION 3.13)

project(freertos_examples)


# Tell IDF build to link against this target.
# set(IDF_PROJECT_EXECUTABLE afr_demo)
set(IDF_PROJECT_EXECUTABLE freertos_examples)
set(IDF_EXECUTABLE_SRCS /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/src/main.c)

# Add some extra components. IDF_EXTRA_COMPONENT_DIRS is an variable used by ESP-IDF
# to collect extra components.
# get_filename_component(
#     EXTRA_COMPONENT_DIRS
#     "components/foo" ABSOLUTE
# )
# list(APPEND IDF_EXTRA_COMPONENT_DIRS ${EXTRA_COMPONENT_DIRS})

# As of now there's no offical way to redefine config files outside of FreeRTOS source tree.
# This is a temporary approach to inject an include path so that this takes precedence over the
# config file directory inside FreeRTOS.
include_directories(BEFORE freertos-configs)
option(AFR_ENABLE_DEMOS "Build demos for FreeRTOS." ON)
# From documentation: idf.py -DVENDOR=espressif -DBOARD=esp32_devkitc -DCOMPILER=xtensa-esp32 build
# add_compile_definitions(COMPILER=xtensa-esp32)
# Add freertos as an subdirectory. AFR_BOARD tells which board to target.
set(AFR_BOARD espressif.esp32_devkitc CACHE INTERNAL "")
add_subdirectory(freertos)

# Link against the mqtt demo so that we can use it. Dependencies of this demo are transitively
# linked.
target_link_libraries(
    freertos_examples
    PRIVATE
    AFR::ble
    AFR::ota
    # AFR::ota_ble
    # AFR::ota::mcu_port
    # AFR::dev_mode_key_provisioning
    AFR::demo_base
    # Add dependency on the ota_demo_dependencies metadata module
    # so that FreeRTOS console shows this demo ONLY when the OTA library
    # (or another library depending on OTA) is selected on the console.
    # AFR::ota_demo_dependencies
)
idf.py -DCMAKE_TOOLCHAIN_FILE=freertos/tools/cmake/toolchains/xtensa-esp32.cmake build
Executing action: all (aliases: build)
Running ninja in directory /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build
Executing "ninja all"...
[0/2] Re-checking globbed directories...
[1/2] Re-running CMake...
-- Submodule update
Skipping submodule '../../../libraries/abstractions/backoff_algorithm/'
Skipping submodule '../../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/coreHTTP/'
Skipping submodule '../../../libraries/coreHTTP/'
Skipping submodule '../../../libraries/coreHTTP/'
Skipping submodule '../../../libraries/coreJSON/'
Skipping submodule '../../../libraries/coreJSON/'
Skipping submodule '../../../libraries/coreJSON/'
Skipping submodule '../../../libraries/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT-Agent/source/dependency/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT-Agent/source/dependency/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT-Agent/source/dependency/coreMQTT/'
Skipping submodule '../../../libraries/device_defender_for_aws/'
Skipping submodule '../../../libraries/device_defender_for_aws/'
Skipping submodule '../../../libraries/device_defender_for_aws/'
Skipping submodule '../../../libraries/device_shadow_for_aws/'
Skipping submodule '../../../libraries/device_shadow_for_aws/'
Skipping submodule '../../../libraries/device_shadow_for_aws/'
Skipping submodule '../../libraries/freertos_plus/standard/freertos_plus_tcp/'
Skipping submodule '../../libraries/freertos_plus/standard/freertos_plus_tcp/'
Skipping submodule '../../libraries/freertos_plus/standard/freertos_plus_tcp/'
Skipping submodule '../../../libraries/jobs_for_aws/'
Skipping submodule '../../../libraries/jobs_for_aws/'
Skipping submodule '../../../libraries/jobs_for_aws/'
Skipping submodule '../../../libraries/ota_for_aws/'
Skipping submodule '../../../libraries/ota_for_aws/source/dependency/coreJSON/'
Skipping submodule '../../../libraries/ota_for_aws/source/dependency/coreJSON/'
Skipping submodule '../../../libraries/ota_for_aws/source/dependency/coreJSON/'
WARNING: IDF_PATH environment variable is not cleared.
    If CMake is generating an error, consider clearing the IDF_PATH environment
    variable, and generating a clean build. This message can be ignored if
    CMake was successful.
-- Component directory /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/mbedtls does not contain a CMakeLists.txt file. No component will be added
-- Component directory /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/unity does not contain a CMakeLists.txt file. No component will be added
-- Checking Python dependencies...
Python requirements from /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/requirements.txt are satisfied.
-- Project sdkconfig file /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig
Loading defaults file /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults...
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:21 CONFIG_NIMBLE_ENABLED was replaced with CONFIG_BT_NIMBLE_ENABLED
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:22 CONFIG_NIMBLE_MAX_CONNECTIONS was replaced with CONFIG_BT_NIMBLE_MAX_CONNECTIONS
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:23 CONFIG_NIMBLE_MAX_BONDS was replaced with CONFIG_BT_NIMBLE_MAX_BONDS
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:24 CONFIG_NIMBLE_MAX_CCCDS was replaced with CONFIG_BT_NIMBLE_MAX_CCCDS
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:25 CONFIG_NIMBLE_L2CAP_COC_MAX_NUM was replaced with CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:26 CONFIG_NIMBLE_PINNED_TO_CORE was replaced with CONFIG_BT_NIMBLE_PINNED_TO_CORE
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:27 CONFIG_NIMBLE_ROLE_CENTRAL was replaced with CONFIG_BT_NIMBLE_ROLE_CENTRAL
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:28 CONFIG_NIMBLE_ROLE_PERIPHERAL was replaced with CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:29 CONFIG_NIMBLE_ROLE_BROADCASTER was replaced with CONFIG_BT_NIMBLE_ROLE_BROADCASTER
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:30 CONFIG_NIMBLE_ROLE_OBSERVER was replaced with CONFIG_BT_NIMBLE_ROLE_OBSERVER
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:31 CONFIG_NIMBLE_NVS_PERSIST was replaced with CONFIG_BT_NIMBLE_NVS_PERSIST
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:32 CONFIG_NIMBLE_SM_LEGACY was replaced with CONFIG_BT_NIMBLE_SM_LEGACY
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:33 CONFIG_NIMBLE_SM_SC was replaced with CONFIG_BT_NIMBLE_SM_SC
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:34 CONFIG_NIMBLE_DEBUG was replaced with CONFIG_BT_NIMBLE_DEBUG
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:35 CONFIG_NIMBLE_SVC_GAP_DEVICE_NAME was replaced with CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:36 CONFIG_NIMBLE_GAP_DEVICE_NAME_MAX_LEN was replaced with CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:37 CONFIG_NIMBLE_ATT_PREFERRED_MTU was replaced with CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:38 CONFIG_NIMBLE_SVC_GAP_APPEARANCE was replaced with CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:39 CONFIG_NIMBLE_ACL_BUF_COUNT was replaced with CONFIG_BT_NIMBLE_ACL_BUF_COUNT
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:40 CONFIG_NIMBLE_ACL_BUF_SIZE was replaced with CONFIG_BT_NIMBLE_ACL_BUF_SIZE
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:41 CONFIG_NIMBLE_HCI_EVT_BUF_SIZE was replaced with CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:42 CONFIG_NIMBLE_HCI_EVT_HI_BUF_COUNT was replaced with CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:43 CONFIG_NIMBLE_HCI_EVT_LO_BUF_COUNT was replaced with CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/sdkconfig.defaults:44 CONFIG_NIMBLE_MESH was replaced with CONFIG_BT_NIMBLE_MESH
/tmp/confgen_tmpymr73lfk:20 line was updated to CONFIG_BT_BLUEDROID_ENABLED=n
/tmp/confgen_tmpymr73lfk:34 line was updated to CONFIG_BT_NIMBLE_DEBUG=n
/tmp/confgen_tmpymr73lfk:44 line was updated to CONFIG_BT_NIMBLE_MESH=n
-- App "freertos_examples" version: 1
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/esp-idf/esp32/esp32_out.ld
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp32/ld/esp32.project.ld.in
-- Adding linker script /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp32/ld/esp32.peripherals.ld
=========================Resolving dependencies==========================
module disabled: posix
reason:          posix::mcu_port is not defined by vendor.
dependency path: posix->posix::mcu_port


====================Configuration for FreeRTOS====================
  Version:                 202107.00
  Git version:             202107.00-28-g3416de7b8

Target microcontroller:
  vendor:                  Espressif
  board:                   ESP32-DevKitC
  description:             Development board produced by Espressif that comes in two 
                           variants either with ESP-WROOM-32 or ESP32-WROVER module
  family:                  ESP32
  data ram size:           520KB
  program memory size:     4MB

Host platform:
  OS:                      Linux-5.4.0-84-generic
  Toolchain:               xtensa-esp32
  Toolchain path:          /home/vasko/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/
                           xtensa-esp32-elf
  CMake generator:         Ninja

FreeRTOS modules:
  Modules to build:        backoff_algorithm, ble, ble_hal, ble_wifi_provisioning, 
                           common, common_io, core_http, core_http_demo_dependencies, 
                           core_json, core_mqtt, core_mqtt_agent, core_mqtt_agent_demo_
                           dependencies, core_mqtt_demo_dependencies, crypto, 
                           dev_mode_key_provisioning, device_defender, device_defender_
                           demo_dependencies, device_shadow, device_shadow_demo_
                           dependencies, freertos_cli_plus_uart, freertos_plus_cli, 
                           greengrass, http_demo_helpers, jobs, jobs_demo_dependencies, 
                           kernel, logging, mqtt_agent_interface, mqtt_demo_helpers, 
                           mqtt_subscription_manager, ota, ota_demo_dependencies, 
                           ota_demo_version, pkcs11, pkcs11_helpers, pkcs11_
                           implementation, pkcs11_utils, platform, secure_sockets, tls, 
                           transport_interface_secure_sockets, wifi
  Enabled by user:         ble, ble_hal, ble_wifi_provisioning, common_io, core_http_demo_
                           dependencies, core_json, core_mqtt_agent_demo_dependencies, 
                           core_mqtt_demo_dependencies, device_defender, device_defender_
                           demo_dependencies, device_shadow, device_shadow_demo_
                           dependencies, freertos_cli_plus_uart, freertos_plus_cli, 
                           greengrass, jobs, jobs_demo_dependencies, logging, 
                           ota_demo_dependencies, pkcs11, pkcs11_helpers, pkcs11_
                           implementation, pkcs11_utils, platform, secure_sockets, wifi
  Enabled by dependency:   backoff_algorithm, common, core_http, core_mqtt, 
                           core_mqtt_agent, crypto, demo_base, dev_mode_key_provisioning, 
                           freertos, http_demo_helpers, kernel, mqtt_agent_interface, 
                           mqtt_demo_helpers, mqtt_subscription_manager, ota, 
                           ota_demo_version, pkcs11_mbedtls, tls, transport_interface_
                           secure_sockets, utils
  3rdparty dependencies:   jsmn, mbedtls, pkcs11, tinycbor
  Available demos:         demo_cli_uart, demo_core_http, demo_core_mqtt, demo_core_mqtt_
                           agent, demo_device_defender, demo_device_shadow, 
                           demo_gatt_server, demo_greengrass_connectivity, demo_jobs, 
                           demo_mqtt_ble, demo_numeric_comparison, demo_ota_ble, 
                           demo_ota_core_http, demo_ota_core_mqtt, demo_shadow_ble, 
                           demo_tcp, demo_wifi_provisioning
  Available tests:         
=========================================================================

-- Configuring done
-- Generating done
-- Build files have been written to: /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build
[0/2] Re-checking globbed directories...
[12/30] Building C object freertos/CMakeFiles/freertos_examples.dir/__/src/main.c.obj
../src/main.c: In function 'prvMiscInitialization':
../src/main.c:173:13: warning: unused variable 'uartRet' [-Wunused-variable]
     int32_t uartRet;
             ^~~~~~~
../src/main.c: In function 'xPortGetUserInput':
../src/main.c:289:20: warning: unused variable 'xReturnMessage' [-Wunused-variable]
         BaseType_t xReturnMessage = pdFALSE;
                    ^~~~~~~~~~~~~~
[17/30] Performing build step for 'bootloader'
ninja: no work to do.
[23/28] Building C object freertos/CMakeFiles/freertos_examples.dir/demos/network_manager/aws_iot_network_manager.c.obj
../freertos/demos/network_manager/aws_iot_network_manager.c:277:31: warning: 'tcpIPConnectionParams' defined but not used [-Wunused-variable]
 static IotNetworkServerInfo_t tcpIPConnectionParams = { 0 };
                               ^~~~~~~~~~~~~~~~~~~~~
../freertos/demos/network_manager/aws_iot_network_manager.c:272:32: warning: 'tcpIPCredentials' defined but not used [-Wunused-variable]
 static IotNetworkCredentials_t tcpIPCredentials = { 0 };
                                ^~~~~~~~~~~~~~~~
[24/28] Building C object freertos/CMakeFiles/freertos_example...r/vendors/espressif/boards/ports/ota_pal_for_aws/ota_pal.c.obj
../freertos/vendors/espressif/boards/ports/ota_pal_for_aws/ota_pal.c:80:21: warning: 'TAG' defined but not used [-Wunused-variable]
 static const char * TAG = "ota_pal";
                     ^~~
[27/28] Linking CXX executable freertos_examples
FAILED: freertos_examples 
: && /home/vasko/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++ -mlongcalls -Wl,--gc-sections -Wl,--cref -Wl,--Map=freertos_examples.map -Wl,--undefined=uxTopUsedPriority freertos/CMakeFiles/freertos_examples.dir/__/src/main.c.obj freertos/CMakeFiles/freertos_examples.dir/libraries/freertos_plus/standard/utils/src/iot_system_init.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp_bignum.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp_mem.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp_hardware.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/mbedtls_debug.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp_aes_xts.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp_sha.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp_timing.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/net_sockets.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp32/aes.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp32/sha.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp32/bignum.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp32/esp_sha1.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp32/esp_sha512.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/esp-idf/components/mbedtls/port/esp32/esp_sha256.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/boards/ports/common_io/iot_i2c.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/boards/ports/common_io/iot_spi.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/boards/ports/common_io/iot_uart.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/boards/ports/ota_pal_for_aws/ota_pal.c.obj freertos/CMakeFiles/freertos_examples.dir/vendors/espressif/boards/ports/ota_pal_for_aws/aws_esp_ota_ops.c.obj freertos/CMakeFiles/freertos_examples.dir/demos/demo_runner/aws_demo.c.obj freertos/CMakeFiles/freertos_examples.dir/demos/network_manager/aws_iot_network_manager.c.obj freertos/CMakeFiles/freertos_examples.dir/demos/demo_runner/iot_demo_freertos.c.obj freertos/CMakeFiles/freertos_examples.dir/demos/demo_runner/iot_demo_runner.c.obj -o freertos_examples  freertos/afr_wifi.a  freertos/afr_ble.a  freertos/afr_common_io.a  -fno-rtti  -fno-lto  freertos/afr_ble.a  freertos/afr_ota.a  freertos/afr_ota.a  freertos/afr_core_json.a  freertos/afr_dev_mode_key_provisioning.a  freertos/afr_ble_wifi_provisioning.a  freertos/afr_wifi.a  freertos/afr_secure_sockets.a  freertos/afr_tls.a  freertos/afr_wifi.a  freertos/afr_secure_sockets.a  freertos/afr_tls.a  freertos/afr_pkcs11_implementation.a  freertos/afr_pkcs11.a  freertos/afr_pkcs11_implementation.a  freertos/afr_pkcs11.a  freertos/afr_pkcs11_utils.a  freertos/afr_crypto.a  freertos/afr_ble.a  freertos/afr_ble_hal.a  freertos/afr_ble.a  freertos/afr_ble_hal.a  freertos/afr_platform.a  freertos/afr_logging.a  freertos/afr_common.a  freertos/afr_platform.a  freertos/afr_logging.a  freertos/afr_common.a  esp-idf/bt/libbt.a  esp-idf/cxx/libcxx.a  esp-idf/newlib/libnewlib.a  esp-idf/freertos/libfreertos.a  esp-idf/heap/libheap.a  esp-idf/log/liblog.a  esp-idf/lwip/liblwip.a  esp-idf/soc/libsoc.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_system/libesp_system.a  esp-idf/xtensa/libxtensa.a  esp-idf/esp32/libesp32.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/pthread/libpthread.a  esp-idf/app_trace/libapp_trace.a  esp-idf/vfs/libvfs.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/ulp/libulp.a  esp-idf/efuse/libefuse.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/driver/libdriver.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp_event/libesp_event.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcore.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libpp.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/librtc.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libphy.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/cxx/libcxx.a  esp-idf/newlib/libnewlib.a  esp-idf/freertos/libfreertos.a  esp-idf/heap/libheap.a  esp-idf/log/liblog.a  esp-idf/lwip/liblwip.a  esp-idf/soc/libsoc.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_system/libesp_system.a  esp-idf/xtensa/libxtensa.a  esp-idf/esp32/libesp32.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/pthread/libpthread.a  esp-idf/app_trace/libapp_trace.a  esp-idf/vfs/libvfs.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/ulp/libulp.a  esp-idf/efuse/libefuse.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/driver/libdriver.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp_event/libesp_event.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcore.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libpp.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/librtc.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libphy.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/cxx/libcxx.a  esp-idf/newlib/libnewlib.a  esp-idf/freertos/libfreertos.a  esp-idf/heap/libheap.a  esp-idf/log/liblog.a  esp-idf/lwip/liblwip.a  esp-idf/soc/libsoc.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_system/libesp_system.a  esp-idf/xtensa/libxtensa.a  esp-idf/esp32/libesp32.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/pthread/libpthread.a  esp-idf/app_trace/libapp_trace.a  esp-idf/vfs/libvfs.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/ulp/libulp.a  esp-idf/efuse/libefuse.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/driver/libdriver.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp_event/libesp_event.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcore.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libpp.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/librtc.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libphy.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  esp-idf/cxx/libcxx.a  esp-idf/newlib/libnewlib.a  esp-idf/freertos/libfreertos.a  esp-idf/heap/libheap.a  esp-idf/log/liblog.a  esp-idf/lwip/liblwip.a  esp-idf/soc/libsoc.a  esp-idf/esp_common/libesp_common.a  esp-idf/esp_system/libesp_system.a  esp-idf/xtensa/libxtensa.a  esp-idf/esp32/libesp32.a  esp-idf/nvs_flash/libnvs_flash.a  esp-idf/esp_timer/libesp_timer.a  esp-idf/esp_ipc/libesp_ipc.a  esp-idf/pthread/libpthread.a  esp-idf/app_trace/libapp_trace.a  esp-idf/vfs/libvfs.a  esp-idf/esp_wifi/libesp_wifi.a  esp-idf/esp_eth/libesp_eth.a  esp-idf/esp_netif/libesp_netif.a  esp-idf/tcpip_adapter/libtcpip_adapter.a  esp-idf/soc/soc/esp32/libsoc_esp32.a  esp-idf/espcoredump/libespcoredump.a  esp-idf/ulp/libulp.a  esp-idf/efuse/libefuse.a  esp-idf/esp_http_client/libesp_http_client.a  esp-idf/esp_http_server/libesp_http_server.a  esp-idf/bootloader_support/libbootloader_support.a  esp-idf/app_update/libapp_update.a  esp-idf/spi_flash/libspi_flash.a  esp-idf/wpa_supplicant/libwpa_supplicant.a  esp-idf/driver/libdriver.a  esp-idf/perfmon/libperfmon.a  esp-idf/esp_event/libesp_event.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcoexist.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libcore.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libespnow.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libmesh.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libnet80211.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libpp.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/librtc.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libsmartconfig.a  ../freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32/libphy.a  esp-idf/nghttp/libnghttp.a  esp-idf/esp-tls/libesp-tls.a  esp-idf/tcp_transport/libtcp_transport.a  esp-idf/esp_ringbuf/libesp_ringbuf.a  -u __cxa_guard_dummy  -lstdc++  esp-idf/pthread/libpthread.a  -u __cxx_fatal_exception  -lm  esp-idf/newlib/libnewlib.a  -u newlib_include_locks_impl  -u newlib_include_heap_impl  -u newlib_include_syscalls_impl  -u newlib_include_pthread_impl  -L /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_rom/esp32/ld  -T esp32.rom.newlib-time.ld  -T esp32.rom.ld  -T esp32.rom.libgcc.ld  -T esp32.rom.newlib-data.ld  -T esp32.rom.syscalls.ld  -T esp32.rom.newlib-funcs.ld  -Wl,--gc-sections  ../freertos/vendors/espressif/esp-idf/components/xtensa/esp32/libhal.a  -lgcc  -L /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/esp-idf/esp32  -T esp32_out.ld  -u app_main  -L /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/esp-idf/esp32/ld  -T esp32.project.ld  -L /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp32/ld  -T esp32.peripherals.ld  -u call_user_start_cpu0  -u ld_include_panic_highint_hdl  -Wl,--wrap=vPortCleanUpTCB  -u pthread_include_pthread_impl  -u pthread_include_pthread_cond_impl  -u pthread_include_pthread_local_storage_impl  esp-idf/app_trace/libapp_trace.a  -lgcov  esp-idf/app_trace/libapp_trace.a  -lgcov  -lc  -u vfs_include_syscalls_impl  -L /home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/esp_wifi/lib/esp32  -u esp_app_desc  freertos/libraries/3rdparty/libafr_3rdparty_mbedtls.a  -L/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/freertos/vendors/espressif/esp-idf/components/bt/controller/lib  -lbtdm_app  freertos/afr_kernel.a  freertos/libraries/3rdparty/libafr_3rdparty_tinycbor.a && :
/home/vasko/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: freertos/CMakeFiles/freertos_examples.dir/demos/network_manager/aws_iot_network_manager.c.obj:(.literal._bleRegisterUnregisterCb+0x4): undefined reference to `vDemoBLEGAPPairingStateChangedCb'
/home/vasko/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: freertos/CMakeFiles/freertos_examples.dir/demos/network_manager/aws_iot_network_manager.c.obj:(.literal._bleRegisterUnregisterCb+0x8): undefined reference to `vDemoBLENumericComparisonCb'
/home/vasko/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: freertos/CMakeFiles/freertos_examples.dir/demos/network_manager/aws_iot_network_manager.c.obj:(.literal.AwsIotNetworkManager_EnableNetwork+0x10): undefined reference to `vDemoBLENumericComparisonInit'
/home/vasko/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: freertos/CMakeFiles/freertos_examples.dir/demos/network_manager/aws_iot_network_manager.c.obj: in function `_bleEnable':
/home/vasko/embd/esp32/amazon-template-examples/amazon-freertos-examples/build/../freertos/demos/network_manager/aws_iot_network_manager.c:393: undefined reference to `vDemoBLENumericComparisonInit'
/home/vasko/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: freertos/CMakeFiles/freertos_examples.dir/demos/demo_runner/iot_demo_runner.c.obj:(.data.mqttDemoContext$5226+0x4): undefined reference to `RunOtaMqttBLETransportDemo'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Hey, I made some edits to the files, but not much progress on the build side. I forked the repo and pushed a new edits, maybe it will be easier to check everything that way: VasilyRakche/amazon-freertos-examples on Github. Idea was to establish everything working with the latest amazon-freertos release since the intial repo of amazon-freertos-examples was established for some older revision. I was setting up BLE MQTT OTA example from the amazon-freertos setup, to work in this configuration - custom project structure. Would really appreciate some insights how to set it up properly.

I have only a tenuous grasp on cmake, but I wonder if you need something like the afr_module_sources line visible here: https://github.com/aws/amazon-freertos/blob/main/demos/ota/ota_demo_core_mqtt/CMakeLists.txt

Hey,
The way I understand it, is that the module is basically creating a library that you can link and use in your program, but since the idea is to just build my program as executable and link needed libraries from FreeRtos, not sure how to apply your suggestion.

It looks as though your project is not building iot_ble_numericComparison.c into your final executable even though it is needed to run the demo. You can simply link AFR::numeric_comparison.

Additionally, the compiler is also trying to find a definition for RunOtaMqttBLETransportDemo, and this exists under AFR::ota_ble. I noticed you commented it out, but I believe that linking that module should fix your issues.