Undefined references sur des variables globales
Bonjour.
J'ai un petit soucis de compilation. En fait, j'ai des variables globales et extern que je déclare dans un fichier "approx.h". J'aimerais les utiliser dans "approx.c" mais à la compilation, gcc me crache ceci :
Citation:
Compiling: approx.c
/home/moons/Etudes/ProgConc/CalculPi/approx.c: In function ‘init’:
/home/moons/Etudes/ProgConc/CalculPi/approx.c:8: warning: implicit declaration of function ‘malloc’
/home/moons/Etudes/ProgConc/CalculPi/approx.c:8: warning: incompatible implicit declaration of built-in function ‘malloc’
/home/moons/Etudes/ProgConc/CalculPi/approx.c:19: warning: passing argument 1 of ‘pthread_create’ makes pointer from integer without a cast
/usr/include/pthread.h:227: note: expected ‘pthread_t * __restrict__’ but argument is of type ‘pthread_t’
/home/moons/Etudes/ProgConc/CalculPi/approx.c:10: warning: unused variable ‘master_mutex’
/home/moons/Etudes/ProgConc/CalculPi/approx.c:9: warning: unused variable ‘produit_mutex’
Linking console executable: bin/Debug/CalculPi
obj/Debug/approx.o: In function `init':
/home/moons/Etudes/ProgConc/CalculPi/approx.c:12: undefined reference to `indice_prod'
/home/moons/Etudes/ProgConc/CalculPi/approx.c:13: undefined reference to `indice_cons'
/home/moons/Etudes/ProgConc/CalculPi/approx.c:14: undefined reference to `production'
collect2: ld returned 1 exit status
Et voici mon makefile:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| # Makefile calculPi
CC = gcc # compiler/linker frontend
INCL = -I$(INCL_DIR) # includes
DEFS = -D_DEBUG_ # defines
CFLAGS = -g $(INCL) $(DEFS) # compiler flags
LFLAGS = -lpthread -lm -g # linker flags
OBJ = approx.o producteur.o sequentialApproximation.o main.o
BIN = calculPi.exe
LINKOBJ = approx.o producteur.o sequentialApproximation.o main.o
RM = rm -fv
all: $(BIN)
clean:
${RM} *\~ \#*\# $(OBJ)
clean_all: clean
${RM} $(BIN)
cleanall: clean
${RM} $(BIN)
$(BIN): $(OBJ)
$(CC) $(LFLAGS) -o $@ $^
main.o: main.c
approx.o: approx.c approx.h
producteur.o: producteur.c producteur.h
sequentialApproximation.o : sequentialApproximation.c sequentialApproximation.h
.c.o:
$(CC) $(CFLAGS) -c $< |
Je ne vois pas pourquoi dans approx.c, les références des variables quand je les appelle ne sont pas reconnues.
Merci de votre aid.