简体   繁体   中英

Why does g++ linker complain about header file?

I am building a C++ app using g++ on linux. I have a mixture of .c and .cpp files and the makefile invokes gcc or g++ accordingly. The linker fails with:

gcc -Wall -c -O2 -I/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/ -include /root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/rte_config.h cfg.c
gcc -Wall -c -O2 -I/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/ -include /root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/rte_config.h mran_structs.c
g++ -Wall -c -O2 -msse4.1 -I/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/ -include /root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/rte_config.h -std=c++11 main.cpp
gcc -Wall -c -O2 -I/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/ -include /root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/rte_config.h wrap_ip.c
gcc -Wall -c -O2 -I/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/ -include /root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/rte_config.h wrap_eth.c
g++ -Wall -c -O2 -msse4.1 -I/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/ -include /root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/include/rte_config.h -std=c++11 dpdk_socket.cpp
g++ Log.c cfg.o mran_structs.o main.o  wrap_ip.o wrap_eth.o dpdk_socket.o -o l2fwd_adapted -L/root/dpdk-2.2.0/x86_64-native-linuxapp-gcc/lib -Wl,--whole-archive -lrte_distributor -lrte_reorder -lrte_kni -lrte_pipeline -lrte_table -lrte_port -lrte_timer -lrte_hash -lrte_jobstats -lrte_lpm -lrte_power -lrte_acl -lrte_meter -lrte_sched -lm -lrt -lrte_vhost -Wl,--start-group -lrte_kvargs -lrte_mbuf -lrte_mbuf_offload -lrte_ip_frag -lethdev -lrte_cryptodev -lrte_mempool -lrte_ring -lrte_eal -lrte_cmdline -lrte_cfgfile -lrte_pmd_ixgbe -lrt -lm -ldl -Wl,--end-group -Wl,--no-whole-archive -lconfig -lstdc++ -lpthread
In file included from CommonFunc.h:8:0,
             from Log.c:16:
dpdkstd.h:14:24: fatal error: rte_common.h: No such file or directory
compilation terminated.
Makefile:39: recipe for target 'l2fwd_adapted' failed

I don't understand why the linker is complaining that it can't find a header file. Surely that should be a concern only at the compilation stage?

I don't know how to fix the error.

I don't understand why the linker is complaining that it can't find a header file.

It's not.

Surely that should be a concern only at the compilation stage?

It is. You are compiling Log.c , which references rte_common.h .

I don't know how to fix the error.

Fix it the way you fix any other such error: provide the path to the header, or move the header, or install the missing third-party library.

In this case, either copy that -include flag that you have in all the other build commands, or if you actually meant Log.o rather than Log.c , correct the typo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM