我有一个简单的守护程序-
https://gist.github.com/RAvenGEr/9563c051de35662d64baf26a8cd66d2e
我在makefile中添加了--coverage标志,如下所示:
CC = g++
CFLAGS = -I. -Wall --coverage
all: daemon-name clean
daemon-name: daemon-name.o
$(CC) -o $@ $^
chmod 700 daemon-name
daemon-name.o: daemon-name.cpp
$(CC) -c $(CFLAGS) $<
clean:
rm *.o
我在编译程序时得到-
Undefined symbols for architecture x86_64:
"_llvm_gcda_emit_arcs", referenced from:
___llvm_gcov_writeout in daemon-name.o
"_llvm_gcda_emit_function", referenced from:
___llvm_gcov_writeout in daemon-name.o
"_llvm_gcda_end_file", referenced from:
___llvm_gcov_writeout in daemon-name.o
"_llvm_gcda_start_file", referenced from:
___llvm_gcov_writeout in daemon-name.o
"_llvm_gcda_summary_info", referenced from:
___llvm_gcov_writeout in daemon-name.o
"_llvm_gcov_init", referenced from:
___llvm_gcov_init in daemon-name.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
请注意,程序在没有--coverage标志的情况下可以正确编译和链接,但是我确实需要查看daemon-name.cpp的覆盖范围
我认为导致错误的原因是链接器不解释--coverage标志。如何将--coverage标志添加到链接器以查看代码覆盖率。