Skip to main content
Erenburg.Evgeny
Associate III
February 21, 2018
Question

Library compile error

  • February 21, 2018
  • 4 replies
  • 1852 views
Posted on February 21, 2018 at 12:47

I've included STM32_USB-FS-Device_Driver in my project. When I compile (in IAR) I get a bunch of errors

Error[Li006]: duplicate definitions for 'Receive_Buffer'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_init.o'

Error[Li006]: duplicate definitions for 'Send_length'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_init.o'

Error[Li006]: duplicate definitions for 'Receive_Buffer'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_int.o'

Error[Li006]: duplicate definitions for 'Send_length'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_int.o'

Error[Li006]: duplicate definitions for 'Receive_Buffer'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_mem.o'

Error[Li006]: duplicate definitions for 'Send_length'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_mem.o'

Error[Li006]: duplicate definitions for 'Receive_Buffer'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_regs.o'

Error[Li006]: duplicate definitions for 'Send_length'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_regs.o'

Error[Li006]: duplicate definitions for 'Receive_Buffer'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_sil.o'

Error[Li006]: duplicate definitions for 'Send_length'; in 'F:\MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_core.o', and 'F:\

MotorControlSolution\MultiAxisMotorControl\AxisManager\Firmware\STM32F303VC\Debug\Obj\usb_sil.o'

Error while running Linker

What is wrong?

    This topic has been closed for replies.

    4 replies

    Tesla DeLorean
    Guru
    February 21, 2018
    Posted on February 21, 2018 at 12:55

    Perhaps a #define is missing, or you're including mutually exclusive things?

    Look at the two places the things are supposedly defined, and try to understand the context for their inclusion.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Andrew Neil
    Super User
    February 21, 2018
    Posted on February 21, 2018 at 13:08

    What is wrong?

    Exactly what it tells you:

    Error[Li006]: duplicate definitions for 'Receive_Buffer';

    in

    '...\usb_core.o',

    and

    '...

    usb_init.o'

    So, as

    Turvey.Clive.002

    ‌ says,

    1. look at the listed files
    2. find where the definitions are duplicated
    3. remove the 'spurious' one.

    Do you, perhaps, have definitions (rather than just declarations) in a header file somewhere ... ?

    http://c-faq.com/decl/decldef.html

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Erenburg.Evgeny
    Associate III
    February 21, 2018
    Posted on February 21, 2018 at 13:13

    There is no

    Receive_Buffer inclusion

    - not in

    usb_core

    .c/h not in

    usb_init

    .c/h. Nothing to be 'duplicate'.

    Besides it's  STM  USB Library - I didn't write a line of code in it.

    I've just opened a demo project (from STM32373C-EVAL_FW_V1.0.0) and it compiles OK - with this library (STM32_USB-FS-Device_Driver).

    0690X00000609ljQAA.png

    But in my project the library compiled with errors.

    Andrew Neil
    Super User
    February 21, 2018
    Posted on February 21, 2018 at 13:21

    There is no

    Receive_Buffer inclusion

    - not in

    usb_core

    .c/h not in

    usb_init

    .c/h. Nothing to be 'duplicate'.

    But clearly there is - that is exactly what IAR is telling you in those messages.

    Maybe examine the preprocessor output to see exactly what is happening with ♯ includes and conditionals ...

    (sorry, I don't use IAR so I don't know the specific options to get the preprocessor output - you will have to check your IAR documentation, or ask IAR).

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    AvaTar
    Senior III
    February 21, 2018
    Posted on February 21, 2018 at 13:31

    As this is a linker error, perhaps you have a variable defined twice, in two different modules ?

    If so, change one into a declaration.

    Andrew Neil
    Super User
    February 21, 2018
    Posted on February 21, 2018 at 13:41

    There's no 'perhaps' - that is exactly what the messages are saying!

    They even tell you exactly which two modules both contain the definitions.

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    AvaTar
    Senior III
    February 21, 2018
    Posted on February 21, 2018 at 14:12

    There's no 'perhaps' - that is exactly what the messages are saying!

    Those error messages refer generically to an object, which could be a function as well - therefore the 'perhaps'.

    Only the name 'Receive_Buffer' suggests it is a variable.

    Andrew Neil
    Super User
    February 21, 2018
    Posted on February 21, 2018 at 14:07

    It does seem that, in all those messages, 

    usb_core.o contains one of the duplicated definitions.

    That suggests:

    • either all of the definitions should be in 

      usb_core.o, and the others should just be accessing them as 'extern';

       
    • or none of the definitions should be in 

      usb_core.o - it should just be accessing them as 'extern' from the other modules.

    Again, as you have a working build 

    from STM32373C-EVAL_FW_V1.0.0, I would start by looking at that to see how it's done.

    Then look at your project to see where it's gone wrong.

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.