Describing header file locations in makefile

2019-05-10 01:30发布

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?


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

2条回答
做个烂人
2楼-- · 2019-05-10 02:18

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

查看更多
男人必须洒脱
3楼-- · 2019-05-10 02:34

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

-IProject_base/h

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

查看更多
登录 后发表回答