This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Project multiple definition

Hi, I am working on an IoT project that will use lwm2m, I developed an event manager architecture using the helloworld example base. Now that I am starting to develop the lwm2m part using the lwm2m client sample I am unable to compile due to multiple definitions of the lwm2m_device.c file


build/zephyr && /opt/nordic/ncs/v1.7.0/toolchain/Cellar/cmake/3.21.1/bin/cmake -E echo
/opt/nordic/ncs/v1.7.0/toolchain/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.bfd: modules/nrf/subsys/net/lib/lwm2m_client_utils/lib..__nrf__subsys__net__lib__lwm2m_client_utils.a(lwm2m_device.c.obj):/opt/nordic/ncs/v1.7.0/nrf/subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_device.c:16: multiple definition of `log_dynamic_lwm2m_device'; app/libapp.a(lwm2m_device.c.obj):/Users/mac/Documents/Kenko/Proyectos/IoT/Base/Kenko_IoT_Base/src/modules/lwm2m/lwm2m_device.c:9: first defined here
/opt/nordic/ncs/v1.7.0/toolchain/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.bfd: modules/nrf/subsys/net/lib/lwm2m_client_utils/lib..__nrf__subsys__net__lib__lwm2m_client_utils.a(lwm2m_device.c.obj):/opt/nordic/ncs/v1.7.0/nrf/subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_device.c:16: multiple definition of `log_const_lwm2m_device'; app/libapp.a(lwm2m_device.c.obj):/Users/mac/Documents/Kenko/Proyectos/IoT/Base/Kenko_IoT_Base/src/modules/lwm2m/lwm2m_device.c:9: first defined here
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/v1.7.0/toolchain/bin/cmake --build /Users/mac/Documents/Kenko/Proyectos/IoT/Base/Kenko_IoT_Base/build

As you can see the compilation finds a previous file in the ncs subsys folder, I took a look at the application but I don't find how they use only the lwm2m_device.c file located in the source file and not the one in the subways folder

Parents
  • Hi,

    The symbols that you have multiple definitions of comes from the LOG_MODULE_REGISTER macro.

    In your case, you have the same module name in both places. The lwm2m_utils has a log module called "lwm2m_device", while the sample calls its log module "app_lwm2m_device".

    If you change the module name in Kenko_IoT_Base/src/modules/lwm2m/lwm2m_device.c to something else than "lwm2m_device", the error should go away.

    Best regards,

    Didrik

Reply
  • Hi,

    The symbols that you have multiple definitions of comes from the LOG_MODULE_REGISTER macro.

    In your case, you have the same module name in both places. The lwm2m_utils has a log module called "lwm2m_device", while the sample calls its log module "app_lwm2m_device".

    If you change the module name in Kenko_IoT_Base/src/modules/lwm2m/lwm2m_device.c to something else than "lwm2m_device", the error should go away.

    Best regards,

    Didrik

Children
Related