I have a question about makefiles used in linux to run c files.
i wrote the following makefile, the purpose is to build the tests regarding the adt's of the program (space,set,arrangement,and plane) and well as to check another program called mtm_space (the first bloc after defining strings)
CC=gcc
OBJS=plane.o set.o space.o main. decoding.o arrangement.o
DEBUG=# insert -g
CFLAGS=-std=c99 -Wall -Werror $(DEBUG) -pedantic-errors/
-DNDEBUG -L. lmtm2
space : $(OBJS)
$(CC) $(CFLAGS) -o $@ $^
arrangement.o: arrangement.c arrangement.h set.h plane.h
decoding.o: decoding.c space.h list.h arrangement.h set.h plane.h \
mtm_ex2.h
plane.o: plane.c plane.h
main.o: main.c space.h list.h arrangement.h set.h plane.h mtm_ex2.h \
decoding.h
set.o: set.c set.h
space.o: space.c space.h list.h arrangement.h set.h plane.h
mtm_space.o: mtmspace.c arrangement.h plane.h list.h set.h space.h mtm_ex2.h/
decoding.h
OBJS1=$(OBJS) space_test.o
space_test : $(OBJS1)
$(CC) $(CFLAGS) -o $@ $^
arrangement.o: arrangement.c arrangement.h set.h plane.h
main.o: main.c space.h list.h arrangement.h set.h plane.h mtm_ex2.h \
decoding.h
plane.o: plane.c plane.h
set.o: set.c set.h
space.o: space.c space.h list.h arrangement.h set.h plane.h
space_test.o: ./tests/space_test.c space.h list.h arrangement.h set.h plane.h
OBJS2= plane.o set.o
plane_test :$(OBJS2)
$(CC) $(CFLAGS) -o $@ $^
plane.o: plane.c plane.h
set.o: set.c set.h
plane_test.o: ./tests/plane_test.c set.h plane.h
OBJS3= set.o
set_test :$(OBJS3)
$(CC) $(CFLAGS) -o $@ $^
set.o:set.c set.h
set_test.o: ./tests/set_test.c set.h
OBJS4= plane.o set.o arrangement.o
arrangement_test :$(OBJS4)
$(CC) $(CFLAGS) -o $@ $^
arrangement.o: arrangement.c arrangement.h set.h plane.h
plane.o: plane.c plane.h
set.o: set.c set.h
arrangement_test.o: ./tests/arrangement_test.c arrangement.h set.h plane.h
but when for instance i try to use
>make space_test
it returns many errors that all look like this
space_test.c:(.text+0x5fc): undefined reference to `spaceCreate'
for all of the different functions i've used.
Can anyone help me figure out why this is happening? the programs all run ok on eclipse Thanks a lot