在GCC中将包含路径添加到父目录 [英] Adding an include path to the parent directory in GCC

查看:91
本文介绍了在GCC中将包含路径添加到父目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将父目录中的文件包含在我正在处理的项目中.所有的头文件都在父目录中,是否可以在命令行上使用-I在不使用绝对路径的情况下在父目录中搜索包含项?

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?

我知道我可以使用Makefile解决这些问题,我可能最终会这样做,但是我想知道是否可以使用快速命令行技巧,因为这种情况在我制作时会弹出很多快速的原型代码.

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

,但这似乎无法正常工作.我是否还需要将simple.cpp中的包含内容从#include include_file.hpp更改为#include ../include_file.hpp?

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 ../include_file.hpp ?

推荐答案

嗯...

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

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

应该工作.

这篇关于在GCC中将包含路径添加到父目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆