S
Student
Hi all,
While compiling a program I had this message :
tools.o(.data+0x0): multiple definition of `VAR_1'
main.o(.data+0x0): first defined here
tools.o(.data+0x4): multiple definition of `VAR_2'
main.o(.data+0x4): first defined here
tools.o(.data+0x8): multiple definition of `VAR_3'
main.o(.data+0x8): first defined here
tools.o(.data+0xc): multiple definition of `VAR_4'
main.o(.data+0xc): first defined here
tools.o(.data+0x10): multiple definition of `VAR_5'
main.o(.data+0x10): first defined here
the structure is :
1/ main.c including a main.h where is defined VAR_1, ... ,VAR_5 as :
const char * VAR_1= ...
2/ In tools.c I include main.h too,
Yes it's normal with this situation that I got the message, but I use
in the head of main.h :
#ifndef MAIN_H
#define MAIN_H
....
#endif /* MAIN_H*/
which means (for me) that if it's already defined MAIN_H will not been
redefined.
To compile I use a makefile those are some lines of this makefile:
main.o: main.c
$(CC) -c $(ALL_CFLAGS) main.c -o main.o
tools.o:tools.c
$(CC) -c $(ALL_CFLAGS) tools.c -o tools.o
main: main.o tools.o
$(CC) main.o tools.o -o main $(LIBRARIES)
Anyone have an idea?
Best Regards.
Hicham
While compiling a program I had this message :
tools.o(.data+0x0): multiple definition of `VAR_1'
main.o(.data+0x0): first defined here
tools.o(.data+0x4): multiple definition of `VAR_2'
main.o(.data+0x4): first defined here
tools.o(.data+0x8): multiple definition of `VAR_3'
main.o(.data+0x8): first defined here
tools.o(.data+0xc): multiple definition of `VAR_4'
main.o(.data+0xc): first defined here
tools.o(.data+0x10): multiple definition of `VAR_5'
main.o(.data+0x10): first defined here
the structure is :
1/ main.c including a main.h where is defined VAR_1, ... ,VAR_5 as :
const char * VAR_1= ...
2/ In tools.c I include main.h too,
Yes it's normal with this situation that I got the message, but I use
in the head of main.h :
#ifndef MAIN_H
#define MAIN_H
....
#endif /* MAIN_H*/
which means (for me) that if it's already defined MAIN_H will not been
redefined.
To compile I use a makefile those are some lines of this makefile:
main.o: main.c
$(CC) -c $(ALL_CFLAGS) main.c -o main.o
tools.o:tools.c
$(CC) -c $(ALL_CFLAGS) tools.c -o tools.o
main: main.o tools.o
$(CC) main.o tools.o -o main $(LIBRARIES)
Anyone have an idea?
Best Regards.
Hicham