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

multiple definition of `SWI2_EGU2_IRQHandler' (when trying to add NFC support to light_switch_server Bluetooth Mesh example)

Hi,

I am working on a Bluetooth Mesh project in which I am trying to add support for NFC, but I get the following error "error: multiple definition of `SWI2_EGU2_IRQHandler'", which occurs in <MESH_SDK_2.2>/common/src/mesh_softdevice_init.c:62. 

I am building on top of the example for the light_switch example with the "Generic OnOff Server" (without the Mesh Proxy; in Mesh SDK 2.2). The project is also using pulse-width-modulation (PWM) based on the "pwm_library" example. Now I am trying to add support for NFC based on the "nfc/record_text" example, but I am unable to compile (because of the error above).

My understanding is that the "nfc/record_text" example is simpler, because it does not involve the SoftDevice. So, I had to make several adjustments (app_config.h/sdk_config.h and CMakeLists.txt) to my project to deal with that fact, without success so far.

I understand that many different things could be going wrong here, so I am not asking to anyone to do my work for me. Hehe Slight smile I will continue troubleshooting my issue, but, in the meantime, I was wondering if anyone had experienced this error (error: multiple definition of `SWI2_EGU2_IRQHandler' ) in a similar context, and, if so, how that error could be fixed.

Thank you for your time and support. A+

Frank

Parents
  • I was wondering if anyone had experienced this error (error: multiple definition of `SWI2_EGU2_IRQHandler' ) in a similar context,

    Yes:  it is a general 'C' thing - nothing specific to Nordic.

    The error means what it says - you have multiple (ie, more than one) definitions of SWI2_EGU2_IRQHandler

     I am unable to compile (because of the error above).

    Are you sure it's a compiler error - not a Linker error ?

    how that error could be fixed

    Remove the excess definition(s)!

    You haven't mentioned what toolchain & IDE you're using, but they do usually tell you where all the definitions were found - so you need to look through them, and decide which to keep, and which to remove.

    failing that, just do a search through your project for all occurrences of "SWI2_EGU2_IRQHandler"

Reply
  • I was wondering if anyone had experienced this error (error: multiple definition of `SWI2_EGU2_IRQHandler' ) in a similar context,

    Yes:  it is a general 'C' thing - nothing specific to Nordic.

    The error means what it says - you have multiple (ie, more than one) definitions of SWI2_EGU2_IRQHandler

     I am unable to compile (because of the error above).

    Are you sure it's a compiler error - not a Linker error ?

    how that error could be fixed

    Remove the excess definition(s)!

    You haven't mentioned what toolchain & IDE you're using, but they do usually tell you where all the definitions were found - so you need to look through them, and decide which to keep, and which to remove.

    failing that, just do a search through your project for all occurrences of "SWI2_EGU2_IRQHandler"

Children
  • ,

    Thank you for helping me out!

    You are right to say that it's a Linker error (not compiler), and that the error is not specific to Nordic.

    I followed your advice and investigated further to find out what the problem was:

    • In the Mesh SDK example for the Generic OnOff Server (without Proxy feature), the SoftDevice is initialized using the mesh_softdevice_init() function, which comes from mesh_softdevice_init.c, which is where SWI2_EGU2_IRQHandler gets defined first.
    • But when I added support for NFC, the latter needed nrf_sdh.c (among other things), which is also defining SWI2_EGU2_IRQHandler (and performing other tasks similar to what mesh_softdevice_init.c does).
    • So to solve the issue, I removed mesh_softdevice_init.c from my CMakeLists.txt, and, in main.c, I replaced the call to mesh_softdevice_init() with nrf_sdh_enable_request().

    Now it works!

    Once more, thank you for your advice. A+

    Frank

Related