Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

valeriogiampa

Member level 3
Joined
Jul 3, 2008
Messages
58
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Location
ITALY
Activity points
1,897
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
 
Last edited by a moderator:

skogsjanne

Full Member level 3
Joined
May 28, 2009
Messages
172
Helped
26
Reputation
52
Reaction score
26
Trophy points
1,308
Activity points
2,084
Have you forgotten the little "extern" in the h file?
 

valeriogiampa

Member level 3
Joined
Jul 3, 2008
Messages
58
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Location
ITALY
Activity points
1,897
The variable are defined in e .h file and use in the .c file. In the main file I don't use this variable. only i call the function that is developed without in-out parameters.
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:



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

Best Regards

Valerio
 

skogsjanne

Full Member level 3
Joined
May 28, 2009
Messages
172
Helped
26
Reputation
52
Reaction score
26
Trophy points
1,308
Activity points
2,084
The conventional way to write C-programs is to declare stuff in h-files and put definitions in c-files.
A silly example with two c-files and one h-file:

Code:
/* example.h */
#ifndef __EXAMPLE_H
#define __EXAMPLE_H
extern int counter;
void displayCounter(void);
#endif

Code:
/* example.c */
#include "example.h"

int counter;

int main(int argc, char **argv)
{

  for (;;) {
    counter++;

    displayCounter();
  }

} /* main */

Code:
/* display.c */
#include "example.h"
#include <stdio.h>

void displayCounter(void)
{

  printf("%d ", counter);

} /* displayCounter */
It can be compiled like this: gcc -Wall -o example example.c display.c
The #ifndef stuff in the header file is to avoid declaring things more than one time.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top