I have a makefile that content like this:
ALL: Compile Execute
Compile:
gcc -I ./include/ -o ./lib/Uretim.o -c ./src/Uretim.c
gcc -I ./include/ -o ./lib/AUretim.o -c ./src/AUretim.c
gcc -I ./include/ -o ./lib/BUretim.o -c ./src/BUretim.c
gcc -I ./include/ -o ./lib/Taktik.o -c ./src/Taktik.c
gcc -I ./include/ -o ./lib/Ataktik.o -c ./src/Ataktik.c
gcc -I ./include/ -o ./lib/Btaktik.o -c ./src/Btaktik.c
gcc -I ./include/ -o ./lib/Koloni.o -c ./src/Koloni.c
gcc -I ./include/ -o ./lib/Oyun.o -c ./src/Oyun.c
@echo :"denem"
gcc -I ./include/ -o ./bin/Test ./lib/Uretim.o ./lib/AUretim.o ./lib/BUretim.o ./lib/Taktik.o ./lib/Ataktik.o ./lib/Btaktik.o ./lib/Koloni.o ./lib/Oyun.o ./src/Test.c
@echo :"denem"
Execute:
./bin/Test
at the line that come after first echo I get redefiniton error for all headers. How can I fix this problem?
sample error:
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./lib/AUretim.o:AUretim.c:(.bss+0x0): multiple definition of `URETIM'; ./lib/Uretim.o:Uretim.c:(.bss+0x0): first defined here
my Uretim.h file:
#ifndef URETIM_H
#define URETIM_H
struct URETIM
{
int deger;
void (*degerdegistirU)(struct URETIM *,int );
int (*Uret)(struct URETIM *);
void (*yoketU)(struct URETIM *);
int (*degerdondurU)();
}URETIM;
typedef struct URETIM *Uretim;
#endif
AUretim.h:
#ifndef AURETIM_H
#define AURETIM_H
#include "Uretim.h"
struct AURETIM
{
struct URETIM * super;
int (*degerDondurUA)(struct AURETIM *);
void (*AyoketU)(struct AURETIM *);
}AURETIM;
typedef struct AURETIM *Auretim;
#endif
koloni.h:
#ifndef KOLONI_H
#define KOLONI_H
#include "ATaktik.h"
#include "BTaktik.h"
#include "AUretim.h"
#include "BUretim.h"
struct KOLONI
{
ATaktik atak;
BTaktik batak;
Auretim auret;
Buretim BUret;
int (* stokgetir)(struct KOLONI *);
int ( * populasyongetir)(struct KOLONI *);
char (*sembolgetir)(struct KOLONI *);
void (*Uretimyap)(struct KOLONI *);
int (*Savasyap)(struct KOLONI *,struct KOLONI *);
void (*Populasyonduzenle)(struct KOLONI *,int);
void (*stokDuzenle)(struct KOLONI *,int);
}KOLONI;
typedef struct KOLONI *Koloni;
#endif
Oyun.h:
#ifndef OYUN_H
#define OYUN_H
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>
#include "Koloni.h"
struct OYUN
{
void (*kolonisavasi)(struct KOLONI *,struct KOLONI *);
}OYUN;
typedef struct OYUN *Oyun;
// typedef struct KOLONI *Koloni;
Oyun oyunolustur();
#endif
I have give my header files content and their including. When I have create object file for each source every think okey.But if I link this object file to Test.c that have main function I take sample error