[英]Adding header files to g++ command
我正在嘗試手動將我的 header 文件路徑添加到 g++
Adams-MBP:randomCode naghs$ g++ -o
-I/Users/naghs/randomCode/lib/StanfordCPPLib/collections/lexicon.h test test.cpp
test.cpp:5:10: fatal error: 'lexicon.h' file not found
#include "lexicon.h"
^~~~~~~~~~~
1 error generated.
這樣做的正確方法是什么,因為我會認為“-I”會那樣做
它是-I/Users/naghs/randomCode/lib/StanfordCPPLib/collections
。 它指定目錄,而不是文件。
-I
標志采用一個目錄,而不是一個單獨的 header 文件。
有關詳細信息,請參閱gcc/g++ 目錄選項文檔。
我也相信你在-o
標志之后有一個不正確的參數。 我想你想要
g++ -I/Users/naghs/randomCode/lib/StanfordCPPLib/collections -o test test.cpp
您應該在-o
標志之后立即擁有 output 路徑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.