This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Failing to compile Thread example after updating OpenThread library

Hi all, I tried to modify the OpenThread's source codes(Just modify an API) and then built them.

  • Run the build_gcc_libs.bat script to build all of the libraries. That's OK.
  • After the libraries are built, use the provided script (<InstallFolder>/external/openthread/project/import_gcc_libs.bat) to copy the compiled libraries to the output folder.
  • Copy the /external/project/openthread/include folder into the /external/openthread folder.

Everything was fine until I tried to recompile the examples with the latest libraries. I don't know what is wrong, please find here below the error log. Such as:

openthread/src/core/thread/mle.cpp:403: undefined reference to `otPlatSettingsSet'

E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\examples\thread\experimental\cli\uart\pca10056\blank\armgcc>make
Compiling file: thread_utils.c
Linking target: _build/nrf52840_xxaa.out
../../../../../../../../external/openthread/lib/gcc/libopenthread-cli-ftd.a(cli_uart.cpp.o):(.rodata._ZTIN2ot3Cli6ServerE[_ZTIN2ot3Cli6ServerE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-cli-ftd.a(cli_uart.cpp.o):(.rodata._ZTIN2ot3Cli4UartE+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dataset_local.cpp.o): In function `ot::MeshCoP::DatasetLocal::Clear()':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:63: undefined reference to `otPlatSettingsDelete'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dataset_local.cpp.o): In function `ot::MeshCoP::DatasetLocal::IsPresent() const':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:68: undefined reference to `otPlatSettingsGet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dataset_local.cpp.o): In function `ot::MeshCoP::DatasetLocal::Get(ot::MeshCoP::Dataset&)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:78: undefined reference to `otPlatSettingsGet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dataset_local.cpp.o): In function `ot::MeshCoP::DatasetLocal::Get(otOperationalDataset&) const':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:111: undefined reference to `otPlatSettingsGet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dataset_local.cpp.o): In function `ot::MeshCoP::DatasetLocal::Set(otOperationalDataset const&)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:367: undefined reference to `otPlatSettingsDelete'
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:372: undefined reference to `otPlatSettingsSet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dataset_local.cpp.o): In function `ot::MeshCoP::DatasetLocal::Set(ot::MeshCoP::Dataset const&)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:395: undefined reference to `otPlatSettingsDelete'
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dataset_local.cpp:400: undefined reference to `otPlatSettingsSet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(instance.cpp.o): In function `ot::Instance::AfterInit()':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/common/instance.cpp:128: undefined reference to `otPlatSettingsInit'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(instance.cpp.o): In function `ot::Instance::FactoryReset()':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/common/instance.cpp:199: undefined reference to `otPlatSettingsWipe'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(key_manager.cpp.o): In function `ot::KeyManager::ComputeKey(unsigned long, unsigned char*)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/key_manager.cpp:156: undefined reference to `__cxa_end_cleanup'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(key_manager.cpp.o):(.ARM.extab.text._ZN2ot10KeyManager10ComputeKeyEmPh+0x0): undefined reference to `__gxx_personality_v0'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mac.cpp.o): In function `~AesCcm':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/crypto/aes_ccm.hpp:59: undefined reference to `__cxa_end_cleanup'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mac.cpp.o):(.ARM.extab.text._ZN2ot3Mac3Mac23ProcessTransmitSecurityERNS0_5FrameE+0x0): undefined reference to `__gxx_personality_v0'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mac.cpp.o): In function `~AesCcm':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/crypto/aes_ccm.hpp:59: undefined reference to `__cxa_end_cleanup'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mac.cpp.o):(.ARM.extab.text._ZN2ot3Mac3Mac22ProcessReceiveSecurityERNS0_5FrameERKNS0_7AddressEPNS_8NeighborE+0x0): undefined reference to `__gxx_personality_v0'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle.cpp.o): In function `ot::Mle::Mle::Store()':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle.cpp:403: undefined reference to `otPlatSettingsSet'
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle.cpp:411: undefined reference to `otPlatSettingsGet'
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle.cpp:422: undefined reference to `otPlatSettingsSet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle.cpp.o): In function `ot::Mle::Mle::Restore()':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle.cpp:303: undefined reference to `otPlatSettingsGet'
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle.cpp:330: undefined reference to `otPlatSettingsGet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle.cpp.o): In function `~AesCcm':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/crypto/aes_ccm.hpp:59: undefined reference to `__cxa_end_cleanup'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle.cpp.o):(.ARM.extab.text._ZN2ot3Mle3Mle11SendMessageERNS_7MessageERKNS_3Ip67AddressE+0x0): undefined reference to `__gxx_personality_v0'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle.cpp.o): In function `~AesCcm':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/crypto/aes_ccm.hpp:59: undefined reference to `__cxa_end_cleanup'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle.cpp.o):(.ARM.extab.text._ZN2ot3Mle3Mle16HandleUdpReceiveERNS_7MessageERKNS_3Ip611MessageInfoE+0x0): undefined reference to `__gxx_personality_v0'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle_router.cpp.o): In function `ot::Mle::MleRouter::RestoreChildren()':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle_router.cpp:3655: undefined reference to `otPlatSettingsGet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle_router.cpp.o): In function `ot::Mle::MleRouter::RemoveStoredChild(unsigned short)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle_router.cpp:3690: undefined reference to `otPlatSettingsGet'
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle_router.cpp:3696: undefined reference to `otPlatSettingsDelete'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle_router.cpp.o): In function `ot::Mle::MleRouter::StoreChild(unsigned short)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle_router.cpp:3723: undefined reference to `otPlatSettingsAdd'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mle_router.cpp.o): In function `ot::Mle::MleRouter::RefreshStoredChildren()':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/thread/mle_router.cpp:3733: undefined reference to `otPlatSettingsDelete'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(netif.cpp.o):(.rodata._ZTIN2ot15InstanceLocatorE[_ZTIN2ot15InstanceLocatorE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(netif.cpp.o):(.rodata._ZTIN2ot3Ip65NetifE[_ZTIN2ot3Ip65NetifE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(thread_api.cpp.o): In function `otThreadGetAutoStart':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/api/thread_api.cpp:508: undefined reference to `otPlatSettingsGet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(thread_api.cpp.o): In function `otThreadSetAutoStart':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/api/thread_api.cpp:525: undefined reference to `otPlatSettingsSet'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(thread_netif.cpp.o):(.rodata._ZTIN2ot11ThreadNetifE+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(coap.cpp.o):(.rodata._ZTIN2ot4Coap4CoapE[_ZTIN2ot4Coap4CoapE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(coap.cpp.o):(.rodata._ZTIN2ot4Coap15ApplicationCoapE[_ZTIN2ot4Coap15ApplicationCoapE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(coap.cpp.o):(.rodata._ZTIN2ot4Coap8CoapBaseE+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(coap_secure.cpp.o):(.rodata._ZTIN2ot4Coap10CoapSecureE+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dtls.cpp.o): In function `ot::MeshCoP::Dtls::HandleMbedtlsExportKeys(unsigned char const*, unsigned char const*, unsigned int, unsigned int, unsigned int)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/dtls.cpp:374: undefined reference to `__cxa_end_cleanup'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(dtls.cpp.o):(.ARM.extab.text._ZN2ot7MeshCoP4Dtls23HandleMbedtlsExportKeysEPKhS3_jjj+0x0): undefined reference to `__gxx_personality_v0'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(meshcop.cpp.o): In function `ot::MeshCoP::ComputeJoinerId(ot::Mac::ExtAddress const&, ot::Mac::ExtAddress&)':
E:\Git\w-repo\nRF5_SDK_for_Thread_v0.11.0_84a130f\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/meshcop/meshcop.cpp:50: undefined reference to `__cxa_end_cleanup'
../../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(meshcop.cpp.o):(.ARM.extab.text._ZN2ot7MeshCoP15ComputeJoinerIdERKNS_3Mac10ExtAddressERS2_+0x0): undefined reference to `__gxx_personality_v0'
collect2.exe: error: ld returned 1 exit status
../../../../../../../../components/toolchain/gcc/Makefile.common:292: recipe for target '_build/nrf52840_xxaa.out' failed
make: *** [_build/nrf52840_xxaa.out] Error 1

Thank you!

  • Hello,

    Thank you for reporting this issue.

    I have identified two problems with the linker after updating OpenThread with libraries build with GCC on Windows.

    First of all, libopenthread-platform-utils.a is not included in makefiles for our examples. The reason for that is that OpenThread build system silently merges libopenthread-platform-utils.a into libopenthread-nrf82840-sdk.a. Our GCC projects for Windows don't do that, therefore the problem with missing references to otPlatSettingsSet etc. We are going to fix that in next release.

    To fix that problem, modify the Makefile you are using to build your project, and include the missing library:

    # Libraries common to all targets
    LIB_FILES += \
      $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-cli-ftd.a \
      $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-ftd.a \
      $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-platform-utils.a \
      $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-nrf52840-sdk.a \
      $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-diag.a \
      $(SDK_ROOT)/external/openthread/lib/gcc/libmbedcrypto-cc310.a \
      $(SDK_ROOT)/external/nrf_cc310/lib/libcc310_gcc_0.9.0.a \

    Kepp the order of the libraries as in the snippet above, otherwise you may still encounter issues with missing symbols during executable linking (unfortunately linking order makes difference to ld).

    The second issue I've identified is that for some reason, when we use libraries build on Windows, they are missing some C++ runtime sybmbols. To fix that, you need to explicitly tell the linker to use C++ stdlib. To do that, again, modify the project Makefile and replace:

    LIB_FILES += -lc -lnosys -lm

    with the following:

    LIB_FILES += -lc -lnosys -lm -lstdc++

    Applying both of the proposed solutions should fix your linking errors.

    Best Regards,
    Robert

  • Hello Robert

    I use windows gcc, too, and encounter build fail today.

    My environment :

    OS: windows 7
    nordic sdk version: nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac.zip
    openthread git version: 71d4ad3e777672a441e238344290df302ad86bb7

    I follow Nordic online document (https://goo.gl/nH3bYu) to setup environment.

    After updating the latest openthread project from github, the ble_thread_dyn_template example can't build successfully.

    My error log:

    Linking target: _build/nrf52840_xxaa.out
    ../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(instance.cpp.o): In function `ot::Instance::Instanc
    e()':
    E:\Proj\nordic\_threadwc\trunk\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/com
    mon/instance.cpp:90: undefined reference to `ot::LinkRaw::LinkRaw(ot::Instance&)'
    ../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mac.cpp.o): In function `otPlatRadioEnergyScanDone'
    :
    E:\Proj\nordic\_threadwc\trunk\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/mac
    /mac.cpp:402: undefined reference to `ot::LinkRaw::InvokeEnergyScanDone(signed char)'
    ../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mac.cpp.o): In function `otPlatRadioReceiveDone':
    E:\Proj\nordic\_threadwc\trunk\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/mac
    /mac.cpp:1859: undefined reference to `ot::LinkRaw::InvokeReceiveDone(otRadioFrame*, otError)'
    ../../../../../../../external/openthread/lib/gcc/libopenthread-ftd.a(mac.cpp.o): In function `otPlatRadioTxDone':
    E:\Proj\nordic\_threadwc\trunk\external\openthread\project\lib\openthread\ftd\armgcc/../../../../openthread/src/core/mac
    /mac.cpp:1306: undefined reference to `ot::LinkRaw::InvokeTransmitDone(otRadioFrame*, otRadioFrame*, otError)'
    collect2.exe: error: ld returned 1 exit status
    make: *** [_build/nrf52840_xxaa.out] Error 1

    It doesn't work even I modify makefile libopenthread-platform-utils.a into libopenthread-nrf52840-sdk.a.

Related