cancel
Showing results for 
Search instead for 
Did you mean: 

Library compile error

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?

10 REPLIES 10
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 Venmo Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Chief II
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

AvaTar
Lead
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
Chief II
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.

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.

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).

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.

Posted on February 21, 2018 at 13:42

erenburg.evgeny.002 wrote:

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).

But in my project the library compiled with errors.

So there is something wrong in your project causing the duplication.

Compare the two projects.

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.