Take this files:
a.h
#ifndef A_H
#define A_H
char EL[] = "el";
#endif
a.cpp
#include "a.h"
b.h
#ifndef B_H
#define B_H
#include "a.h"
#endif
b.cpp
#include "b.h"
main.cpp
#include "b.h"
#include "a.h"
int main() { }
This is only an example, but I've really this problem:
g++ -c a.cpp
g++ -c b.cpp
g++ -c main.cpp
g++ -o main main.o a.o b.o
a.o:(.data+0x0): multiple definition of `EL'
main.o:(.data+0x0): first defined here
b.o:(.data+0x0): multiple definition of `EL'
main.o:(.data+0x0): first defined here
collect2: ld returned 1 exit status
why and how to solve?