2

My project structure and files are as follows:

project\HAL\hw_lcd.h
project\HAL\hw_lcd.c
project\project\app.c
project\project\workspace.mcp
project\project\workspace.mcw

Where 'project' is a place holder for project name. I'm using MPLAB IDE 8.66 and HI-TECH Compiler 9.81.

I'd like to add hw_lcd.h/c files using relative path to the project. So that if I write #include "HAL/hw_lcd.h" in app.c, then hw_lcd.h will be found from app.c.

I added ../ as include search path (project > build options... > project > directories and search path > include search path) but got following error:

can't open include file "hw_lcd.h": No such file or directory

Then I tried ../HAL as include search path and written #include "hw_lcd.h" in app.c. This also generates the above error.

Is it possible to use relative search path from within MPLAB IDE?

If the #include path itself is relative, then it works:

#include "../HAL/hw_lcd.h"

1 Answer 1

0

Not entirely the same, but I always use

            #include "hw_lcd.h"

and then add the header to the project, and in the "add" dialog I select "this file is for this project, use relative path" or something similar.

This works fine. (but has the trouble that if paths (e.g. HAL) change, you need to walk over them, and change them all)

Sign up to request clarification or add additional context in comments.

8 Comments

Most likely the absolute path to the directory that contains the file is added in "Include Search Path" from "Build Options" for your project.
It isn't. It is only one level down from the project dir though. And never let the IDE choose automatic, always "use relative". Not unlike yours, just that it is called INCLUDE16 instead of HAL.
Your case it is down. For me it is up from project level.
It's ..\include16 relative to the project dir. So up.
You mean ..\include16 is added to the include search path?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.