wordcount.c :(。text + 0x30):未定义引用`htab_init'

时间:2016-04-17 09:39:36

标签: c reference makefile

嗨我的makefile有问题而且我不知道出了什么问题我尝试了多种可能性而且它没有用,我该怎么办?

标准终端:

gcc -std = c99 -pedantic -Wall -o wordcount -static io.o wordcount.o libhtable.a wordcount.o:在函数main': wordcount.c:(.text+0x30): undefined reference to htab_init' collect2:错误:ld返回1退出状态 make:*** [wordcount]错误1

 CFLAGS=-std=c99 -pedantic -Wall
 CPPFLAGS=-std=c++98 -pedantic -Wall
 PROGS=wordcount wordcount-dynamic
 LIBFILES=htab_clear.o htab_init.o htab_lookup_add.o htab_free.o htab_foreach.o htab_remove.o hash_function.o

 all: $(PROGS)


wordcount.o: wordcount.c htable.h
    gcc $(FLAGS) -c wordcount.c -o wordcount.o

io.o:
    gcc $(CFLAGS) -c io.c -o io.o

hash_function.o: hash_function.c
    gcc $(CFLAGS) -fPIC -c hash_function.c

htab_clear.o: htab_clear.c
    gcc $(CFLAGS) -fPIC -c htab_clear.c -o htab_clear.o

htab_init.o: htab_init.c
    gcc $(CFLAGS) -fPIC -c htab_init.c -o htab_init.o

htab_lookup_add.o: htab_lookup_add.c
    gcc $(CFLAGS) -fPIC -c htab_lookup_add.c -o htab_lookup_add.o

htab_free.o: htab_free.c
    gcc $(CFLAGS) -fPIC -c htab_free.c -o htab_free.o

htab_foreach.o: htab_foreach.c
    gcc $(CFLAGS) -fPIC -c htable_foreach.c -o htable_foreach.o

htab_remove.o: htab_remove.c
    gcc $(CFLAGS) -fPIC -c htab_remove.c -o htab_remove.o



libhtable.a: $(LIBFILES)
    ar crs libhtable.a $(LIBFILES)


libhtable.so: $(LIBFILES)
    gcc $(CFLAGS) -shared -fPIC -o libhtable.so $(LIBFILES)


wordcount: wordcount.o io.o libhtable.a
    gcc $(CFLAGS) -o wordcount -static io.o wordcount.o libhtable.a


wordcount-dynamic: wordcount.o io.o libhtable.so
    gcc $(CFLAGS) -o wordcount-dynamic io.o  wordcount.o libhtable.so

clean:
    rm -f *.o $(PROGS) libhtable.so libhtable.a

0 个答案:

没有答案