描述makefile中的头文件位置

时间:2022-12-30 02:04:27

In a new project I am working on I have the following dir structure:

在我正在开发的新项目中,我有以下目录结构:

Project_base
|---- src
|---- bin
|---- h
| Makefile

And in my source files I have includes that look like so:

在我的源文件中,我包含了如下所示:

#include "../h/SomeHeaderFile.h"

instead of the more correct form:

而不是更正确的形式:

#include "SomeHeaderFile.h"

What do I need to add to my makefile so that I can removed the relative path includes so they will look normal?

我需要添加到我的makefile中,以便我可以删除相对路径包含以使它们看起来正常吗?


ADDITION: also, where do I set this in CDT (C++ for eclipse) so that in design time this is reflected as well?

2 个解决方案

#1


You need to add -I../h in the list of parameters you pass to gcc.

您需要在传递给gcc的参数列表中添加-I ../ h。

#2


Add a flag to your CFLAGS so that the root of the headers is part of the headers search path:

在CFLAGS中添加一个标志,以便标头的根目录成为标题搜索路径的一部分:

-IProject_base/h

That way gcc/g++ will also look here in addition to the default headers directories.

这样,除了默认的头文件目录之外,gcc / g ++也会在这里查看。

#1


You need to add -I../h in the list of parameters you pass to gcc.

您需要在传递给gcc的参数列表中添加-I ../ h。

#2


Add a flag to your CFLAGS so that the root of the headers is part of the headers search path:

在CFLAGS中添加一个标志,以便标头的根目录成为标题搜索路径的一部分:

-IProject_base/h

That way gcc/g++ will also look here in addition to the default headers directories.

这样,除了默认的头文件目录之外,gcc / g ++也会在这里查看。