Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22077

Why does makefile not recognize defined library in C?

$
0
0

I have a program in C that is compiled with gcc from a Makefile. The makefile code:

CC=gcc
CFLAGS=-c -g -Wall -std=gnu99
LDFLAGS=#-pthread

SOURCES=ficheros_basico.c bloques.c mi_mkfs.c leer_SF.c #todos los .c
LIBRARIES=ficheros_basico.o bloques.o #todos los .o de la biblioteca del SF
INCLUDES=ficheros_basico.h bloques.h #todos los .h
PROGRAMS=mi_mkfs leer_SF
OBJS=$(SOURCES:.c=.o)

all: $(OBJS) $(PROGRAMS)

    $(PROGRAMS): $(LIBRARIES) $(INCLUDES)
    $(CC) $(LDFLAGS) $(LIBRARIES) $@.o -o $@

%.o: %.c $(INCLUDES)
    $(CC) $(CFLAGS) -o $@ -c $<

.PHONY: clean
clean:
    rm -rf *.o *~ $(PROGRAMS)

Then I get output:

gcc   mi_mkfs.o   -o mi_mkfs
/usr/bin/ld: mi_mkfs.o: en la función `main':
/home/ehe781/SOII_FS/mi_mkfs.c:9: referencia a `bmount' sin definir
/usr/bin/ld: /home/ehe781/SOII_FS/mi_mkfs.c:12: referencia a `bwrite' sin definir
/usr/bin/ld: /home/ehe781/SOII_FS/mi_mkfs.c:14: referencia a `initSB' sin definir
/usr/bin/ld: /home/ehe781/SOII_FS/mi_mkfs.c:15: referencia a `initMB' sin definir
/usr/bin/ld: /home/ehe781/SOII_FS/mi_mkfs.c:16: referencia a `initAI' sin definir
/usr/bin/ld: /home/ehe781/SOII_FS/mi_mkfs.c:17: referencia a `bumount' sin definir
collect2: error: ld returned 1 exit status
make: *** [<integrado>: mi_mkfs] Error 1

when I execute the makefile. I have defined those functions in bloques.h, and included this in ficheros_basico.h. Finally I included it in mi_mkfs.c, so as I see it, if you go inside of ficheros_basico.h you find the bloques.h include that has the defined functions. Why does the makefile not recognize the function references?

PD:Sorry for the possibly messy question, but I didn't know how to explain it other way.


Viewing all articles
Browse latest Browse all 22077

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>