0

我有一个关于 linux 中用于运行 c 文件的 makefile 的问题。

我编写了以下makefile,目的是构建有关程序的adt(空间,集合,排列和平面)的测试,并检查另一个名为mtm_space的程序(定义字符串后的第一个块)

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

但是例如当我尝试使用

 >make space_test

它返回许多看起来像这样的错误

space_test.c:(.text+0x5fc): undefined reference to `spaceCreate'

对于我使用过的所有不同功能。

谁能帮我弄清楚为什么会这样?程序在 Eclipse 上都可以正常运行 非常感谢

4

0 回答 0