您好,谢谢您的宝贵时间和事先的答复。
我正在尝试使用gcc编译C代码。但是,当我要计算代码覆盖率时,我需要编译代码以支持gcov分析。我知道在一个简单的场景中,您可以使用以下语法来编译代码:
gcc -fprofile-arcs -ftest-coverage
但是,由于有一个包含另一个Makefile的Makefile,因此我无法直接编译代码。 Makefile的内容如下:
CONTIKI_PROJECT = main
all: $(CONTIKI_PROJECT)
CONTIKI=../..
include $(CONTIKI)/Makefile.include
我试图通过CFLAGS
传递参数,Makefile变成这样:
CONTIKI_PROJECT = main
all: $(CONTIKI_PROJECT)
CONTIKI=../..
include $(CONTIKI)/Makefile.include
CC = gcc
CFLAGS += -fprofile-arcs -ftest-coverage
但是当我使用make
进行项目编译时,我得到了以下错误提示:
main.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-unused-const-variable’
LD build/native///main.native
main.o: In function `process_thread_main_process':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/main.c:42: warning: the `gets' function is dangerous and should not be used.
main.o: In function `_GLOBAL__sub_I_65535_0_main_process':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/main.c:49: undefined reference to `__gcov_init'
main.o:(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(contiki-main.o): In function `_GLOBAL__sub_I_65535_0_main':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/contiki-main.c:178: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(contiki-main.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(autostart.o): In function `_GLOBAL__sub_I_65535_0_autostart_start':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/autostart.c:71: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(autostart.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(ctimer.o): In function `_GLOBAL__sub_I_65535_0_ctimer_process':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/ctimer.c:173: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(ctimer.o):(.data+0xa0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(log.o): In function `_GLOBAL__sub_I_65535_0_curr_log_level_rpl':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/log.c:208: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(log.o):(.data+0x1a0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(energest.o): In function `_GLOBAL__sub_I_65535_0_energest_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/energest.c:100: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(energest.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(etimer.o): In function `_GLOBAL__sub_I_65535_0_etimer_process':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/etimer.c:270: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(etimer.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(node-id.o): In function `_GLOBAL__sub_I_65535_0_node_id':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/node-id.c:56: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(node-id.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(process.o): In function `_GLOBAL__sub_I_65535_0_process_list':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/process.c:386: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(process.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rtimer.o): In function `_GLOBAL__sub_I_65535_0_rtimer_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/rtimer.c:105: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rtimer.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(timer.o): In function `_GLOBAL__sub_I_65535_0_timer_set':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/timer.c:146: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(timer.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(list.o): In function `_GLOBAL__sub_I_65535_0_list_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/lib/list.c:347: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(list.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(queuebuf.o): In function `_GLOBAL__sub_I_65535_0_queuebuf_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/queuebuf.c:472: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(queuebuf.o):(.data+0xa0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(packetbuf.o): In function `_GLOBAL__sub_I_65535_0_packetbuf_clear':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/packetbuf.c:234: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(packetbuf.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(netstack.o): In function `_GLOBAL__sub_I_65535_0_netstack_process_ip_callback':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/netstack.c:92: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(netstack.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(linkaddr.o): In function `_GLOBAL__sub_I_65535_0_linkaddr_null':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/linkaddr.c:78: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(linkaddr.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(nullmac.o): In function `_GLOBAL__sub_I_65535_0_nullmac_driver':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/mac/nullmac/nullmac.c:89: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(nullmac.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-ds6.o): In function `_GLOBAL__sub_I_65535_0_uip_ds6_default_prefix':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-ds6.c:761: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-ds6.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uiplib.o): In function `_GLOBAL__sub_I_65535_0_uiplib_ip6addrconv':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uiplib.c:225: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uiplib.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(tcpip.o): In function `_GLOBAL__sub_I_65535_0_tcpip_output':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/tcpip.c:836: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(tcpip.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-ds6-route.o): In function `_GLOBAL__sub_I_65535_0_uip_ds6_route_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-ds6-route.c:748: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-ds6-route.o):(.data+0xa0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-ds6-nbr.o): In function `_GLOBAL__sub_I_65535_0_uip_ds6_neighbors_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-ds6-nbr.c:577: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-ds6-nbr.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip6.o): In function `_GLOBAL__sub_I_65535_0_uip_ext_bitmap':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip6.c:2339: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip6.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-nd6.o): In function `_GLOBAL__sub_I_65535_0_uip_nd6_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-nd6.c:1127: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-nd6.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(simple-udp.o): In function `_GLOBAL__sub_I_65535_0_simple_udp_process':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/simple-udp.c:179: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(simple-udp.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl.o): In function `_GLOBAL__sub_I_65535_0_rpl_lollipop_greater_than':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl.c:265: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-dag.o): In function `_GLOBAL__sub_I_65535_0_rpl_dag_state_to_str':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-dag.c:758: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-dag.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-dag-root.o): In function `_GLOBAL__sub_I_65535_0_rpl_dag_root_print_links':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-dag-root.c:161: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-dag-root.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(platform.o): In function `_GLOBAL__sub_I_65535_0_select_set_callback':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../arch/platform/native/./platform.c:347: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(platform.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(clock.o): In function `_GLOBAL__sub_I_65535_0_clock_time':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../arch/platform/native/./clock.c:101: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(clock.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(tun6-net.o): In function `_GLOBAL__sub_I_65535_0_tun6_net_driver':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../arch/cpu/native/net/tun6-net.c:320: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(tun6-net.o):(.data+0xe0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rtimer-arch.o): In function `_GLOBAL__sub_I_65535_0_rtimer_arch_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../arch/cpu/native/./rtimer-arch.c:91: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rtimer-arch.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(watchdog.o): In function `_GLOBAL__sub_I_65535_0_watchdog_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../arch/cpu/native/./watchdog.c:62: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(watchdog.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(stimer.o): In function `_GLOBAL__sub_I_65535_0_stimer_set':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/sys/stimer.c:162: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(stimer.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(button-hal.o): In function `_GLOBAL__sub_I_65535_0_button_hal_process':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/dev/button-hal.c:229: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(button-hal.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(serial-line.o): In function `_GLOBAL__sub_I_65535_0_serial_line_process':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/dev/serial-line.c:141: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(serial-line.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(leds.o): In function `_GLOBAL__sub_I_65535_0_leds_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/dev/leds.c:223: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(leds.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(nullradio.o): In function `_GLOBAL__sub_I_65535_0_nullradio_driver':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/dev/nullradio.c:106: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(nullradio.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(gpio-hal.o): In function `_GLOBAL__sub_I_65535_0_gpio_hal_register_handler':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/dev/gpio-hal.c:98: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(gpio-hal.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(ringbuf.o): In function `_GLOBAL__sub_I_65535_0_ringbuf_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/lib/ringbuf.c:122: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(ringbuf.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(memb.o): In function `_GLOBAL__sub_I_65535_0_memb_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/lib/memb.c:123: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(memb.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(random.o): In function `_GLOBAL__sub_I_65535_0_random_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/lib/random.c:53: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(random.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(nbr-table.o): In function `_GLOBAL__sub_I_65535_0_nbr_table_register':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/nbr-table.c:444: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(nbr-table.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(link-stats.o): In function `_GLOBAL__sub_I_65535_0_link_stats_from_lladdr':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/link-stats.c:301: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(link-stats.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uipbuf.o): In function `_GLOBAL__sub_I_65535_0_uipbuf_clear':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uipbuf.c:248: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uipbuf.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-icmp6.o): In function `_GLOBAL__sub_I_65535_0_uip_icmp6_input':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-icmp6.c:318: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-icmp6.o):(.data+0xc0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-sr.o): In function `_GLOBAL__sub_I_65535_0_uip_sr_num_nodes':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-sr.c:302: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-sr.o):(.data+0xa0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-packetqueue): In function `_GLOBAL__sub_I_65535_0_uip_packetqueue_new':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-packetqueue.c:85: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-packetqueue):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(uip-udp-packet.): In function `_GLOBAL__sub_I_65535_0_uip_udp_packet_send':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/ipv6/uip-udp-packet.c:101: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(uip-udp-packet.):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-icmp6.o): In function `_GLOBAL__sub_I_65535_0_rpl_icmp6_update_nbr_table':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-icmp6.c:685: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-icmp6.o):(.data+0xe0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-neighbor.o): In function `_GLOBAL__sub_I_65535_0_rpl_neighbors':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-neighbor.c:455: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-neighbor.o):(.data+0x80): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-timers.o): In function `_GLOBAL__sub_I_65535_0_rpl_timers_schedule_periodic_dis':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-timers.c:568: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-timers.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-ext-header.): In function `_GLOBAL__sub_I_65535_0_rpl_ext_header_srh_get_next_hop':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-ext-header.c:488: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-ext-header.):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-nbr-policy.): In function `_GLOBAL__sub_I_65535_0_rpl_nbr_policy_find_removable':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-nbr-policy.c:154: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-nbr-policy.):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(rpl-mrhof.o): In function `_GLOBAL__sub_I_65535_0_rpl_mrhof':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../os/net/routing/rpl-lite/rpl-mrhof.c:303: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(rpl-mrhof.o):(.data+0xc0): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(int-master.o): In function `_GLOBAL__sub_I_65535_0_int_master_enable':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../arch/cpu/native/./int-master.c:66: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(int-master.o):(.data+0x60): undefined reference to `__gcov_merge_add'
build/native///contiki-ng-native.a(gpio-hal-arch.o): In function `_GLOBAL__sub_I_65535_0_gpio_hal_arch_init':
/home/hooman/Downloads/contiki-ng/examples/Development (gcov)/../../arch/cpu/native/dev/gpio-hal-arch.c:221: undefined reference to `__gcov_init'
build/native///contiki-ng-native.a(gpio-hal-arch.o):(.data+0x60): undefined reference to `__gcov_merge_add'
collect2: error: ld returned 1 exit status
../../Makefile.include:406: recipe for target 'build/native///main.native' failed
make: *** [build/native///main.native] Error 1
rm main.o
任何建议都值得赞赏。