cancel
Showing results for 
Search instead for 
Did you mean: 

Error [LI006] - STM32L1xx - IAR - Linker error: Duplicate Definition

valeriogiampa
Associate II
Posted on February 12, 2012 at 01:30

Hi,

I have modified an example project of IAR for STM32L1XX with a new library definition (one file .c and one file .h). In the file .h I have defined a variable that I use in the .c file. The function defined in the .h file are developed in the .c file and used in the main file.

There aren't any duplicate of the variable that I have defined in the .h file, but when I run the make command I can see this message:

Linking

Error[Li006]: duplicate definitions for ''ADC_Counter''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Delay''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\

RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\RAM_Debug\

Obj\main.o''

Error[Li006]: duplicate definitions for ''Frequency''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\

RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\RAM_Debug\

Obj\main.o''

Error[Li006]: duplicate definitions for ''Frequency_Detection''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Gate_Pulse_Off''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Half_Period_Length''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''LED_Blinking''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Period''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\

RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\RAM_Debug\

Obj\main.o''

Error[Li006]: duplicate definitions for ''Period_Counter''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Period_Length''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Period_Prev''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Power_Level''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Power_Level_Prev''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Second_Half_Wave''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Soft_Change_Delay''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Soft_Change_Speed''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Start_Up''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\

RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\RAM_Debug\

Obj\main.o''

Error[Li006]: duplicate definitions for ''Timer''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\

RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\GettingStarted-VG1\RAM_Debug\

Obj\main.o''

Error[Li006]: duplicate definitions for ''Trimmer_Value''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''Turn_On_Delay''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''ZVS_Alarm''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error[Li006]: duplicate definitions for ''ZVS_Alarm_Counter''; in ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\appSource.o'', and ''C:\Users\hp\Desktop\STM32L1xx\Demos_STM32-P152_v1.00\Demos\Projects\

GettingStarted-VG1\RAM_Debug\Obj\main.o''

Error while running Linker

 

Total number of errors: 22

Total number of warnings: 0

One error for variable defined in the .h file. Why?

Can you help me?

Best Regards

Valerio

#error-li006-duplicate-error-iar #li006-duplicate-definitions
19 REPLIES 19
Posted on February 12, 2012 at 02:13

One error for variable defined in the .h file. Why? Can you help me?

Yet you don't provide the file(s) to examine, or a brief snap-shot.

If I have to guess, you are defining variables without using ''extern'' and consequently every file which includes your .H creates a copy of the variable.

foo.h -> extern int bar;

foo.c -> int bar = 0;

main.c -> #include ''foo.h''

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
adnen_speder
Associate II
Posted on February 17, 2012 at 17:27

verifier qu'il ya pas un cour circuit dans votre stm ...

elle m'arrive cet erreur dans un certain temp a cause du cour circuit

william239955
Associate II
Posted on April 06, 2012 at 10:16

I have the same pb, my usage is like follows:

#ifdef INIT_AVER

init.h -> int aver;

init.c -> aver = 0;

#endif

main.c -> #include ''init.h''

william239955
Associate II
Posted on April 06, 2012 at 10:17

I have the same pb, my usage is like follows:

#ifdef INIT_AVER

init.h -> int aver;

init.c -> aver = 0;

#endif

main.c -> #include ''init.h''

frankmeyer9
Associate II
Posted on April 06, 2012 at 10:28

Try this:

init.h -> extern int aver;

william239955
Associate II
Posted on April 06, 2012 at 10:31

I have the same pb, my usage is like follows:

init.h -> #ifdef INIT_AVER

init.h -> int aver;

init.h -> #endif

init.c -> aver = 0;

main.c -> #include ''init.h''

william239955
Associate II
Posted on April 06, 2012 at 10:38

Thanks, I will try.

william239955
Associate II
Posted on April 06, 2012 at 10:52

When I use ''extern'' in init.h, I got the following error:

Error[Li005]: no definition for ''aver'' [referenced from ....\main.o]

frankmeyer9
Associate II
Posted on April 06, 2012 at 11:40

Your distribution of declaration in source files is not clear to me from this posts.

However, one file should define the questioned variable:

int  variable = 0;

or:

extern int  variable = 0;

The other file should see a declaration, for instance from a header:

extern int  variable;

Each variable must be defined once and only once, but can be declared multiple times.

See a C language manual for the difference between definition and declaration.