Home > Enterprise >  Adding header files to g command
Adding header files to g command

Time:03-26

Im trying to manually add my header file path to 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.

What is the correct way to do that because I would've thought that "-I" does that

CodePudding user response:

It's -I/Users/naghs/randomCode/lib/StanfordCPPLib/collections. It specifies a directory, not a file.

CodePudding user response:

The -I flag takes a directory, not an individual header file.

For more info, see gcc/g Directory Options docs.

I also believe you have an incorrect argument after the -o flag. I think you want

g   -I/Users/naghs/randomCode/lib/StanfordCPPLib/collections -o test test.cpp

You should have the output path immediately after your -o flag.

  • Related