2017-02-02 8 views
-2

私はLinux上でg ++を使ってC++アプリケーションを構築しています。私は.cファイルと.cppファイルが混在しているので、makefileはgccまたはg ++を適切に呼び出します。リンカが失敗する:g ++リンカーがヘッダーファイルについて文句を言うのはなぜですか?

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 

なぜリンカがヘッダファイルを見つけることができないと不平を言っているのか分かりません。確かに、それは編集段階でのみ問題になるはずですか?

エラーの修正方法がわかりません。

+2

なぜこれがリンカーエラーであると思われますか? –

+0

'rte_common.h:いいえそのようなファイルやディレクトリ'はリンカから来ません。 – P0W

+0

いいえ、リンカはヘッダーの欠落については不平を言っていませんが、 – Raindrop7

答えて

7

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?

です。 Log.crte_common.hを参照)をコンパイルしています。

I don't know how to fix the error.

はそれをあなたが任意の他のそのようなエラーを修正する方法を修正:ヘッダーへのパスを提供し、またはヘッダーを移動したり、不足しているサードパーティのライブラリをインストールします。この場合

、どちらかあなたが実際にLog.oではなくLog.cを意味している場合、あなたが他のすべてのビルドコマンドに持っている-includeフラグをコピー、または、タイプミスを修正します。

+0

はい、Log.oではなくLog.oを意味していました。申し訳ありませんが自分自身を発見していないが、あなたは私に多くの時間を節約しました。ありがとう! – DavidA

関連する問題