使用makefile时出现多个定义错误

时间:2013-12-21 10:10:16

标签: c++ makefile

我正在尝试使用以下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

它进入了最后的链接阶段,但带来了许多“多重定义错误”:

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输出标志编译了我的中间文件。

1 个答案:

答案 0 :(得分:0)

根据错误消息,我会说:

curllib=src/libcurl/src/curl

是一个程序,而不是一个库。不应该像libcurl.a那样吗?