A proper way of customizing nrf/zephyr libs/examples to get rid of multiple definition errors and conflicts.

Hi,


I am working on ATV2 app and related libs and examples, for example, I need to edit aws_iot.c but I don't want to affect all nrf aws_iot.c lib examples and projects, I just want to apply these changes to my local project to work on some other projects with default libs and configs later, So I copied aws_iot.c to the local project folder and compiled it. but as you guess, I am getting "multiple definition errors" like this below. It is the same error when I want to copy and edit Kconfig files as well.

c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: modules/nrf/subsys/net/lib/aws_iot/lib..__nrf__subsys__net__lib__aws_iot.a(aws_iot.c.obj):C:\ncs\v2.2.0\nrf\subsys\net\lib\aws_iot\src\aws_iot.c:22: multiple definition of `log_const_aws_iot'; app/libapp.a(aws_iot.c.obj):C:\wsc\iotpass\IoTPass\board-test\src\cloud\cloud_codec\aws_iot\aws_iot.c:22: first defined here
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: modules/nrf/subsys/net/lib/aws_iot/lib..__nrf__subsys__net__lib__aws_iot.a(aws_iot.c.obj): in function `aws_iot_ping':
C:\ncs\v2.2.0\nrf\subsys\net\lib\aws_iot\src\aws_iot.c:924: multiple definition of `aws_iot_ping'; app/libapp.a(aws_iot.c.obj):C:\wsc\iotpass\IoTPass\board-test\src\cloud\cloud_codec\aws_iot\aws_iot.c:924: first defined here
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: modules/nrf/subsys/net/lib/aws_iot/lib..__nrf__subsys__net__lib__aws_iot.a(aws_iot.c.obj): in function `aws_iot_keepalive_time_left':
C:\ncs\v2.2.0\nrf\subsys\net\lib\aws_iot\src\aws_iot.c:933: multiple definition of `aws_iot_keepalive_time_left'; app/libapp.a(aws_iot.c.obj):C:\wsc\iotpass\IoTPass\board-test\src\cloud\cloud_codec\aws_iot\aws_iot.c:933: first defined here
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: modules/nrf/subsys/net/lib/aws_iot/lib..__nrf__subsys__net__lib__aws_iot.a(aws_iot.c.obj): in function `aws_iot_input':
C:\ncs\v2.2.0\nrf\subsys\net\lib\aws_iot\src\aws_iot.c:938: multiple definition of `aws_iot_input'; app/libapp.a(aws_iot.c.obj):C:\wsc\iotpass\IoTPass\board-test\src\cloud\cloud_codec\aws_iot\aws_iot.c:938: first defined here
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: modules/nrf/subsys/net/lib/aws_iot/lib..__nrf__subsys__net__lib__aws_iot.a(aws_iot.c.obj): in function `aws_iot_send':
C:\ncs\v2.2.0\nrf\subsys\net\lib\aws_iot\src\aws_iot.c:942: multiple definition of `aws_iot_send'; app/libapp.a(aws_iot.c.obj):C:\wsc\iotpass\IoTPass\board-test\src\cloud\cloud_codec\aws_iot\aws_iot.c:942: first defined here
c:/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: modules/nrf/subsys/net/lib/aws_iot/lib..__nrf__subsys__net__lib__aws_iot.a(aws_iot.c.obj): in function `aws_iot_disconnect':

is there any option to eliminate including sdk libs and configs during compiling to prevent conflicts between zephyrOs libs examples and my project? or Do I have to change the names of the files and functions? I remember when I was working on IAR, eclipse ide, I can add/remove lib paths. 

  • Seems like you are including AWS_IOT libs twice. Once from ncs\v2.2.0\nrf\subsys\net\lib\aws_iot and C:\wsc\iotpass\IoTPass\board-test\src\cloud\cloud_codec\aws_iot\

    If you do not want to include nrf based aws_iot lib just set CONFIG_AWS_IOT=n in your proj.conf so that the sources in ncs\v2.2.0\nrf\subsys\net\lib\aws_iot are not included in your project.

  • Seems like you are including AWS_IOT libs twice. Once from ncs\v2.2.0\nrf\subsys\net\lib\aws_iot and C:\wsc\iotpass\IoTPass\board-test\src\cloud\cloud_codec\aws_iot\

    I know but I am looking for a way to edit and reuse some libs without renaming all functions and configs in my local project. aws_iot libs were just a sample to elaborate on what I want to do.

    for example. If I remove aws_iot libs from the ncs folder, it will work for the project but I don't want to do that because if do that I can't use any more examples and projects depending on aws_iot libs. Is there any way to ignore zephyrOS, nrf libs for the project?

    CONFIG_AWS_IOT=n

    But if I set this config CONFIG_AWS_IOT=n in project files, I won't be able to use even my local aws_iot.c functions unless I configure/rename all functions and config definitions in the local aws_iot.c file. I think there should be some other easy way.

  • Can you attach your project here for me to do a quick compile to understand the conflict in dependency a bit better?

Related