This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Error: L6200E: Symbol multiply defined

I have a code with following files:

- Extern_file.h

int variable = 5;

void function (void);

- Extern_file.c

#include Extern_file.h

void function (void){ variable++; }

- main.c

#include Extern_file.h

int main(void){ function(); return 0; }

When link, I got the error:.\Objects\Blinky_LEDS.axf: Error: L6200E: Symbol variable multiply defined (by Extern_file.o and main.o).
Im working over a code made from component designer (stm32F105) and migrating to nrf51822. This is only a simplified example.
Why can't I link it?
If I use CoIDE I don't have this problem.
I have readed another link about this problem, but I can't solve it.
http://www.keil.com/forum/21633/

Thanks.

Parents
  • Because, as the error message tells you, you have multiple definitions of the symbol 'variable'.

    - Extern_file.h
    
    int variable = 5;
    

    That is almost certainly your problem!

    That is a definition of the symbol 'variable'.

    Therefore, every file which #includes Extern_file.h will contain a definition of the symbol 'variable'.

    Therefore, if multiple (ie, more than one) files #include Extern_file.h, you will obviously have multiple definitions!!

    c-faq.com/.../decldef.html

Reply
  • Because, as the error message tells you, you have multiple definitions of the symbol 'variable'.

    - Extern_file.h
    
    int variable = 5;
    

    That is almost certainly your problem!

    That is a definition of the symbol 'variable'.

    Therefore, every file which #includes Extern_file.h will contain a definition of the symbol 'variable'.

    Therefore, if multiple (ie, more than one) files #include Extern_file.h, you will obviously have multiple definitions!!

    c-faq.com/.../decldef.html

Children
No data