使用makefile时出现多个定义错误 [英] multiple definition errors when using makefile
本文介绍了使用makefile时出现多个定义错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下makefile构建项目:
I'm trying to build my project with the following makefile:
CC=g++
in=main.cpp
out=analyser
series=Series.o
episode=Episode.o
curlandclean=src/htmlfunctions/curlandclean.cpp
pugilib=src/pugixml/src/pugixml.o
curllib=src/libcurl/src/curl
tidylib=src/tidy/tidy-html5-master/lib/libtidy.a
CFLAGS=-c
C11FLAG=-std=c++11
MTFLAG=-fopenmp -lpthread
$(out): analyser
$(out):$(series) $(episode) curlandclean.o $(curllib) $(tidylib) $(pugilib)
$(CC) $(in) $(series) $(episode) curlandclean.o $(curllib) $(tidylib) $(pugilib) $(C11FLAG) -fopenmp -lpthread -o $(out)
curlandclean.o:$(curlandclean)
$(CC) $(CFLAGS) $(curlandclean)
$(series):src/Series.cpp
$(CC) $(CFLAGS) $(C11FLAG) $(MTFLAG) src/Series.cpp
$(episode):src/Episode.cpp
$(CC) $(CFLAGS) src/Episode.cpp
$(curllib):
cd src/libcurl && ./configure --disable-shared
cd src/libcurl && $(MAKE)
$(pugilib):
cd src/pugixml/src && $(CC) $(CFLAGS) pugixml.cpp
$(tidylib):
cd src/tidy/tidy-html5-master && $(MAKE)
clean:
rm *.o
它进入了最后的链接阶段,但伴随着许多多个定义错误":
It gets to the final linking stage but comes with lots of 'multiple definition errors':
src/libcurl/src/curl: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
src/libcurl/src/curl: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
我不确定用-c输出标志编译中间文件时做错了什么.
I'm not sure what I've done wrong as I've compiled my intermediate files with the -c output flag.
推荐答案
基于错误消息,我会这样说:
Based on the error message, I'd say that this:
curllib=src/libcurl/src/curl
是一个程序,而不是一个库.应该不是像libcurl.a
这样的东西吗?
is a program, not a library. Shouldn't it be something like libcurl.a
instead?
这篇关于使用makefile时出现多个定义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文