开发者

Adding an include path to the parent directory in GCC

开发者 https://www.devze.com 2023-02-20 13:00 出处:网络
I\'m wanting to include files from the parent directory in a project I am working on. All of the header files are in the parent directory, is there any way of using -I on the commandline to search for

I'm wanting to include files from the parent directory in a project I am working on. All of the header files are in the parent directory, is there any way of using -I on the commandline to search for includes in the parent directory without using an absolute path?

I know I can solve these issues using a makefile and I will probably end up doing this, but I'd like to know if there is a quick commandline trick I can use as this situation pops up a lot when I am making quick prototype code.

Currently I am trying to compile using:

g++ -Wall -I../ simple.cpp

but this seems to not work properly. Will I also need to change the includes in simple.cpp from #include include_file.hpp to #include ../inclu开发者_StackOverflowde_file.hpp ?


Hmm...

g++ -Wall -I.. simple.cpp

and

// Somewhere in simple.cpp
#include <include_file.hpp>

should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消