Problème pour la compilation séparée
Bonjour,
J'ai fait un programme, et je voudrais le séparer. Seulement je ne comprends pas pourquoi, mais je rencontre l'erreur "multiple definition of *function*" pour toutes mes fonctions... Je trouve pas où j'ai fait une erreur!
Si c'est important, je suis sous windows, je compile avec Cygwin et mon éditeur est Geany. Voilà en gros mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
//bigint.h
#ifndef BIGINT_H
#define BIGINT_H
typedef struct Biginteger* big_integer_t;
big_integer_t bigIntFromString (const char *str, size_t length);
void freeBigInt(big_integer_t a);
void print(big_integer_t bi);
#endif |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
//bigint.c
struct Biginteger
{
char *data;
size_t length;
};
big_integer_t bigIntFromString (const char *str, size_t length)
{
//code
}
void freeBigInt(big_integer_t a)
{
//code
}
void print(big_integer_t bi)
{
//code
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
//main.c
#include <stdio.h>
#include <stdlib.h>
#include "bigint.h"
#include "bigint.c"
int main()
{
//code
return 0;
} |
Code:
1 2 3 4 5 6 7 8
|
makefile
bigint : bigint.o main.o
gcc bigint.o main.o -o bigint
bigint.o : bigint.h bigint.c
gcc -c bigint.c
main.o : bigint.h main.c
gcc -c main.c |
Après avoir fait ca, sur le terminal je fais bien
make
puis
./bigint
?
Voilà... Si vous pouviez m'éclairer... Merci ;)